Post: Need Help on the Basics
03-21-2016, 01:37 PM #1
DH63
Retired Staff
(adsbygoogle = window.adsbygoogle || []).push({}); I have been working on a simple test script to see if I can get a simple button press to print the message "Test" by using threads...but I cannot seem to get it to work.

Can anyone help me out on this? Is it my threading? I'm not entirely sure on what I'm doing wrong with this.

    
/*
* Black Ops 2 - GSC Studio by iMCSx
*
* Creator : dahacka666
* Project : Test Code
* Mode : Zombies
* Date : 2016/03/21 - 00:00:08
*
*/

#include maps\mp\_utility;
#include common_scripts\utility;
#include maps\mp\gametypes_zm\_hud_util;
#include maps\mp\gametypes_zm\_hud_message;

init()
{
level thread onPlayerConnect();
}

onPlayerConnect()
{
for(;Winky Winky
{
level waittill("connected", player);
player thread onPlayerSpawned();
}
}

onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");
for(;Winky Winky
{
self waittill("spawned_player");

wait 2.5;
self iprintln("^2Test Spawn Message with Delay");

self thread TestThread();
}

}

TestThread()
{
if(self ActionSlotOneButtonPressed())
{
self thread TestPrint();
}
}

TestPrint()
{
self iprintln("^2Test");
}
(adsbygoogle = window.adsbygoogle || []).push({});
03-21-2016, 02:59 PM #2
Patrick
League Champion
you need to add a loop to the "TestThread" so it will keep checking to see if you are pressing "ActionSlotOneButtonPressed" Smile

Example:
    TestThread()
{
for(;Winky Winky
{
if(self ActionSlotOneButtonPressed())
{
self thread TestPrint();
}
wait .05;
}
}

The following 2 users say thank you to Patrick for this useful post:

DH63, HiddenHour
03-21-2016, 03:42 PM #3
DH63
Retired Staff
Originally posted by 32085
you need to add a loop to the "TestThread" so it will keep checking to see if you are pressing "ActionSlotOneButtonPressed" Smile

Example:
    TestThread()
{
for(;Winky Winky
{
if(self ActionSlotOneButtonPressed())
{
self thread TestPrint();
}
wait .05;
}
}


Hell yeah it works now! Thanks so much!

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo