Double command.
#1

I made a new script that allows me to open a certain gate.
Now, I want to be able use /gate twice, once to open and once to close, just to save free space, and make everything much easier.
Here is my script, seems like no warnings, but it doesn't work, it only opens one side.

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
     if(
strcmp(cmdtext"/gate"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
IsPlayerInRangeOfPoint(playerid101588.9812011719, -1638.041503906314.952730178833))
            {
                
                
MoveObject(obj1588.9812011719, -1638.04150390637.9527301788332.00);
                
                
            }
        }
        return 
1;
    }
else if(
strcmp(cmdtext"/gate"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
IsPlayerInRangeOfPoint(playerid101588.9812011719, -1638.041503906314.952730178833))
            {
                
MoveObject(obj1588.9812011719, -1638.041503906314.9527301788332.00);
                }
        }
        return 
1;
    } 
Reply
#2

Make a global variable that stores if the gates is open or closed. Then you can check it after strcmp and open/close it

pawn Код:
new gateopen = 0;

...
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/gate", true) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, 1588.9812011719, -1638.0415039063, 14.952730178833))
        {                  
            if(!gateopen) {
                MoveObject(obj, 1588.9812011719, -1638.0415039063, 7.952730178833, 2.00);
                gateopen = 1;
            } else {
                MoveObject(obj, 1588.9812011719, -1638.0415039063, 14.952730178833, 2.00);
                gateopen = 0;
            }                
        }
    return 1;
    }
       
}
I dont know which move opens the gate and which closes it, just swap them if it is wrong.

EDIT: I just noticed, that you do not need the IsPlayerConnected. If a player is not on the server, he cant type a command
Reply
#3

PHP код:
[PHP]C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(232) : warning 219local variable "name" shadows a variable at a preceding level
C
:\Documents and Settings\y\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(293) : warning 209: function "OnPlayerCommandText" should return a value
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(298) : error 010invalid function or declaration
C
:\Documents and Settings\y\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(300) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(301) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(303) : error 010invalid function or declaration
C
:\Documents and Settings\y\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(308) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(310) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(311) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(313) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(319) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(328) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(329) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(332) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(333) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(335) : error 021symbol already defined"dini_IntSet"
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(341) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(348) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(357) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(364) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(366) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(368) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(371) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(373) : error 010invalid function or declaration
C
:\Documents and Settings\y\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(375) : error 010invalid function or declaration
C
:\Documents and Settings\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(382) : error 010invalid function or declaration
C
:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(384) : error 010invalid function or declaration
C
:\Documents and Settings\y\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(389) : error 054unmatched closing brace ("}")
Compilation aborted.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase 
[/PHP]
Reply
#4

Guess ur missing an bracket in there somewhere.
Reply
#5

Where ? can you pinpoint it please I can't find it whatsoever.
Reply
#6

Learn to indent and you will see the bracket missing easily.
Reply
#7

Nothing is wrong as far as I can see with the bracket
Can you help me ?
Reply
#8

Nope i can't this is something you have to figure out yourself.

Read the errors maybe.. : "Cocuments and SettingsyMy DocumentsDownloadssamp03bsvr_R2_win32gamemodesRP.p wn(389) : error 054: unmatched closing brace ("}") "

Try to check out line 389.
Reply
#9

No more warnings, fixed it, but it doesn't work, it only opens to one side, that's all.
Should I add something to the bottom :
PHP код:
     if(IsPlayerInRangeOfPoint(playerid101588.9812011719, -1638.041503906314.952730178833)){
        if(!
gateopen) {
        
MoveObject(obj1588.9812011719, -1638.04150390635.9527301788332.00); }
         }
        
gateopen 1;
        } else {
Bottom :
        
MoveObject(obj1588.9812011719, -1638.041503906314.9527301788332.00);
                
gateopen 0;
            }
        return 
1;
  } 
Reply
#10

Geez, learn to indent..

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, 10, 1588.9812011719, -1638.0415039063, 14.952730178833))
{
    if(!gateopen)
    {
        MoveObject(obj, 1588.9812011719, -1638.0415039063, 5.952730178833, 2.00);
        gateopen = 1;
    }
    else
    {
        MoveObject(obj, 1588.9812011719, -1638.0415039063, 14.952730178833, 2.00);
        gateopen = 0;
    }
    return 1;
}
This forum requires that you wait 120 seconds between posts. Please try again in 7 seconds.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)