How to turn this code into a delay? -
Djsoulhart - 06.03.2014
Okay, so I have written out a pretty sad little code that deals with gates. I basically pieced together what I saw others do for theirs and this code magically worked. Though this maybe only one of the gates I put in I'm curious as to how the hell I push it as a timer rather then a two cmd to open and close.
PHP код:
LSPDgate = CreateObject(969, 1539.57263, -1632.32275, 12.43860, 0.00000, 0.00000, 89.44900);
PHP код:
if (strcmp("/open", cmdtext, true, 12) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 10, 1539.57263, -1632.32275, 12.43860))
{
MoveObject(LSPDgate, 1539.5726, -1625.0808, 12.4386, 6);
SendClientMessage(playerid, 0xEF994300, "The gate have been opened.");
}
return 1;
}
if (strcmp("/close", cmdtext, true, 6) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 10, 1539.57263, -1632.32275, 12.43860))
{
MoveObject(LSPDgate, 1539.57263, -1632.32275, 12.43860, 6);
SendClientMessage(playerid, 0xEF994300, "The gate have been closed.");
}
return 1;
}
Yes, I know it's messy..
I'm as I said before on a different thread I'm new to pawno/this type of coding.
Tbh, I'd like to replace /open , /close with one cmd called "/go" with about a 10 second delay.
Re: How to turn this code into a delay? -
XK - 06.03.2014
you mean you want a command /go and if you /go it opens the gate and after few seconds it closes?and same for closing?
Re: How to turn this code into a delay? -
Djsoulhart - 06.03.2014
Quote:
Originally Posted by XK
you mean you want a command /go and if you /go it opens the gate and after few seconds it closes?and same for closing?
|
I want it so if you type /go it will open the gate, wait ten seconds then closes without having to type in another command.
Re: How to turn this code into a delay? -
Luis- - 06.03.2014
Using a timer will help.
Re: How to turn this code into a delay? -
XK - 06.03.2014
pawn Код:
if (strcmp("/go", cmdtext, true, 12) == 0)
{
if(IsPlayerInRangeOfPoint(playerid, 10, 1539.57263, -1632.32275, 12.43860))
{
MoveDynamicObject(LSPDgate, 1539.5726, -1625.0808, 12.4386, 6);
SendClientMessage(playerid, 0xEF994300, "The gate have been opened.");
SetTimer("LSPDgateCheck", 10000, 0);
}
return 1;
}
pawn Код:
forward LSPDgateCheck();
public LSPDgateCheck()
{
MoveDynamicObject(LSPDgate, 1539.57263, -1632.32275, 12.43860, 6);
}
Re: How to turn this code into a delay? -
Djsoulhart - 06.03.2014
And where do I define "MoveDynamicObject" thats basically the only error I get with that code.
Re: How to turn this code into a delay? -
Keyhead - 06.03.2014
Here -
Streamer
Re: How to turn this code into a delay? -
XK - 06.03.2014
download streamer..
https://sampforum.blast.hk/showthread.php?tid=102865
Re: How to turn this code into a delay? -
Djsoulhart - 06.03.2014
Quote:
Originally Posted by XK
pawn Код:
if (strcmp("/go", cmdtext, true, 12) == 0) { if(IsPlayerInRangeOfPoint(playerid, 10, 1539.57263, -1632.32275, 12.43860)) { MoveDynamicObject(LSPDgate, 1539.5726, -1625.0808, 12.4386, 6); SendClientMessage(playerid, 0xEF994300, "The gate have been opened."); SetTimer("LSPDgateCheck", 10000, 0); } return 1; }
pawn Код:
forward LSPDgateCheck(); public LSPDgateCheck() { MoveDynamicObject(LSPDgate, 1539.57263, -1632.32275, 12.43860, 6); }
|
Okay, so I set up the streamer and logged into my game to test it out.
/go works but it will not move the gate..
Re: How to turn this code into a delay? -
XK - 06.03.2014
pawn Код:
forward LSPDgateCheck();
public LSPDgateCheck()
{
MoveDynamicObject(LSPDgate, 1539.57263, -1632.32275, 12.43860, 6);
return 1;
}