Double command. -
Scriptissue - 27.09.2010
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(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/gate", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInRangeOfPoint(playerid, 10, 1588.9812011719, -1638.0415039063, 14.952730178833))
{
MoveObject(obj, 1588.9812011719, -1638.0415039063, 7.952730178833, 2.00);
}
}
return 1;
}
else if(strcmp(cmdtext, "/gate", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInRangeOfPoint(playerid, 10, 1588.9812011719, -1638.0415039063, 14.952730178833))
{
MoveObject(obj, 1588.9812011719, -1638.0415039063, 14.952730178833, 2.00);
}
}
return 1;
}
Re: Double command. -
Mauzen - 27.09.2010
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
Re: Double command. -
Scriptissue - 27.09.2010
PHP код:
[PHP]C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(232) : warning 219: local 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 010: invalid function or declaration
C:\Documents and Settings\y\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(300) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(301) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(303) : error 010: invalid function or declaration
C:\Documents and Settings\y\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(308) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(310) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(311) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(313) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(319) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(328) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(329) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(332) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(333) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(335) : error 021: symbol already defined: "dini_IntSet"
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(341) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(348) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(357) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(364) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(366) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(368) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(371) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(373) : error 010: invalid function or declaration
C:\Documents and Settings\y\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(375) : error 010: invalid function or declaration
C:\Documents and Settings\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(382) : error 010: invalid function or declaration
C:\Documents and Settings\\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(384) : error 010: invalid function or declaration
C:\Documents and Settings\y\My Documents\Downloads\samp03bsvr_R2_win32\gamemodes\RP.pwn(389) : error 054: unmatched closing brace ("}")
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
[/PHP]
Re: Double command. -
Cameltoe - 27.09.2010
Guess ur missing an bracket in there somewhere.
Re: Double command. -
Scriptissue - 27.09.2010
Where ? can you pinpoint it please I can't find it whatsoever.
Re: Double command. -
Cameltoe - 27.09.2010
Learn to indent and you will see the bracket missing easily.
Re: Double command. -
Scriptissue - 27.09.2010
Nothing is wrong as far as I can see with the bracket
Can you help me ?
Re: Double command. -
Cameltoe - 27.09.2010
Nope i can't this is something you have to figure out yourself.
Read the errors maybe.. : "C

ocuments and SettingsyMy DocumentsDownloadssamp03bsvr_R2_win32gamemodesRP.p wn(389) : error 054: unmatched closing brace ("}") "
Try to check out line 389.
Re: Double command. -
Scriptissue - 27.09.2010
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(playerid, 10, 1588.9812011719, -1638.0415039063, 14.952730178833)){
if(!gateopen) {
MoveObject(obj, 1588.9812011719, -1638.0415039063, 5.952730178833, 2.00); }
}
gateopen = 1;
} else {
Bottom :
MoveObject(obj, 1588.9812011719, -1638.0415039063, 14.952730178833, 2.00);
gateopen = 0;
}
return 1;
}
Re: Double command. -
Cameltoe - 27.09.2010
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.