[SOLVED]run function if key press

Posts 15 of 5 · Page 1 of 1
[SOLVED]run function if key press
Hi!

I will modify my mod and I think I know how to do except this:
I want to run a function when a key is down:

keyPressed()
{
if(self isHost())
{
//give weapon
}
}

How can I check if the specifik key is pressed?
And one more question: Can I write something in the chat wich runs the functions and send an argument with?

Thanks
[php]keypressCheck()
{
self notifyOnPlayerCommand("N", "+actionslot 1"); //Assigns N to actionslot 1
for(;
{
self waittill("N"): //Waits til someone presses N
self thread keyPressed(): //Starts the keyPressed() thread
}
}
keyPressed()
{
if(self isHost()) //If you are host
{
//Do some stuff here
}
}[/php]

If you want to say something through a GSC, use:
self sayall("YourTextHere");
/Marked as Solved
dont forget to self thread in your dovars or onplayerspawned so the script knows the run the thread.
i tryed this code and it didnt seem to work
Posts 15 of 5 · Page 1 of 1
This thread is closed for replies.

Tags for this Thread

Need help?