How to turn this code into a delay?
#1

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 код:
        new LSPDgate
PHP код:
    LSPDgate CreateObject(9691539.57263, -1632.3227512.43860,   0.000000.0000089.44900); 
PHP код:
    if (strcmp("/open"cmdtexttrue12) == 0
    {
        if(
IsPlayerInRangeOfPoint(playerid101539.57263, -1632.3227512.43860))
           {
        
MoveObject(LSPDgate1539.5726, -1625.080812.43866);
                
SendClientMessage(playerid0xEF994300"The gate have been opened."); 
        }
        return 
1;
    }
        if (
strcmp("/close"cmdtexttrue6) == 0)
    {
        if(
IsPlayerInRangeOfPoint(playerid101539.57263, -1632.3227512.43860))
        {
                  
MoveObject(LSPDgate1539.57263, -1632.3227512.438606);
              
SendClientMessage(playerid0xEF994300"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.
Reply
#2

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?
Reply
#3

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.
Reply
#4

Using a timer will help.
Reply
#5

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);
}
Reply
#6

And where do I define "MoveDynamicObject" thats basically the only error I get with that code.
Reply
#7

Here - Streamer
Reply
#8

download streamer..
https://sampforum.blast.hk/showthread.php?tid=102865
Reply
#9

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..
Reply
#10

pawn Код:
forward LSPDgateCheck();
public LSPDgateCheck()
{
    MoveDynamicObject(LSPDgate, 1539.57263, -1632.32275, 12.43860, 6);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)