PDA

View Full Version : Brackets fail i guess.


Kyance
28/09/2013, 04:23 PM
I made a fun command, called "Slenderkidnap"
A random person goes on "Slenderman mode"
And he can /slenderKIDNAP other people.
Well, when i compile it, i get bunch of errors.
So i know it's a brackets fault..
The script(Has explanations):
CMD:slenderkidnap(playerid,params[])
{
if((GetPlayerScore(playerid) > 150) return SendClientMessage(playerid, COLOR_NAVY, "You need 150 score to be the SlenderMan"); //If the player has less than 150 score, he will get this message
return 1;
}
new Float:X,Float:Y,Float:Z,Float:Angle
new id;
if (sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /slenderkidnap [id]"); //if the ID isn't added, then it will show the usage.
if(!IsPlayerConnected(targetid) || targetid == playerid) return SendClientMessage(playerid, COLOR_ORANGE, "This player is offline, or you're trying to kidnap yourself."); //If the player ID isn't "valid".
if(!IsPlayerInRangeOfPoint(playerid,5,X,Y,Z); //if Slenderman is too far from the player (I bet i've failed here)
{
SendClientMessage(playerid, COLOR_RED, "You're too far from the target!");
}
if(IsPlayerInRangeOfPoint(playerid,5,X,Y,Z); //If he is in the range of the player, then the following things will happen.
{
SendClientMessage(id, COLOR_NAVY, "You've got kidnapped!"); //Kidnapped will get this.
SetPlayerInterior(id, 1); //His interior will be set to the meat factory
SetPlayerPos(id, 963.418762,2108.292480,1011.030273); //And the pos.
}
return 1;
}
Errors: [THEY'RE BEFORE AND AFTER THE SCRIPT TOO.]
test.pwn(909) : warning 219: local variable "X" shadows a variable at a preceding leveltest.pwn(909) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(909) : warning 219: local variable "Z" shadows a variable at a preceding level
test.pwn(909) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(918) : warning 219: local variable "X" shadows a variable at a preceding level
test.pwn(918) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(918) : warning 219: local variable "Z" shadows a variable at a preceding level
test.pwn(918) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(934) : warning 219: local variable "X" shadows a variable at a preceding level
test.pwn(934) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(934) : warning 219: local variable "Z" shadows a variable at a preceding level
test.pwn(934) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(1249) : warning 219: local variable "X" shadows a variable at a preceding level
C:\Documents and Settings\Owner\Desktop\gamemode test\gamemodes\test.pwn(1249) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(1249) : warning 219: local variable "Z" shadows a variable at a preceding level
test.pwn(1249) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(1266) : warning 219: local variable "X" shadows a variable at a preceding level
test.pwn(1266) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(1266) : warning 219: local variable "Z" shadows a variable at a preceding level
test.pwn(1266) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(1283) : warning 219: local variable "X" shadows a variable at a preceding level
est.pwn(1283) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(1283) : warning 219: local variable "Z" shadows a variable at a preceding level
test.pwn(1283) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(1300) : warning 219: local variable "X" shadows a variable at a preceding level
test.pwn(1300) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(1300) : warning 219: local variable "Z" shadows a variable at a preceding level
test.pwn(1300) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(1318) : warning 219: local variable "X" shadows a variable at a preceding level
test.pwn(1318) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(1318) : warning 219: local variable "Z" shadows a variable at a preceding level
test.pwn(1318) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(1344) : warning 219: local variable "X" shadows a variable at a preceding level
test.pwn(1344) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(1344) : warning 219: local variable "Z" shadows a variable at a preceding level
test.pwn(1344) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(1361) : warning 219: local variable "X" shadows a variable at a preceding level
test.pwn(1361) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(1361) : warning 219: local variable "Z" shadows a variable at a preceding level
test.pwn(1361) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(1378) : warning 219: local variable "X" shadows a variable at a preceding level
test.pwn(1378) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(1378) : warning 219: local variable "Z" shadows a variable at a preceding level
test.pwn(1378) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(1395) : warning 219: local variable "X" shadows a variable at a preceding level
test.pwn(1395) : warning 219: local variable "Y" shadows a variable at a preceding level
test.pwn(1395) : warning 219: local variable "Z" shadows a variable at a preceding level
\test.pwn(1395) : warning 219: local variable "Angle" shadows a variable at a preceding level
test.pwn(1544) : warning 219: local variable "id" shadows a variable at a preceding level
test.pwn(1614) : error 001: expected token: ")", but found "return"
test.pwn(1618) : error 001: expected token: ";", but found "new"
test.pwn(1619) : error 010: invalid function or declaration
test.pwn(1620) : error 010: invalid function or declaration
test.pwn(1621) : error 010: invalid function or declaration
test.pwn(1625) : error 010: invalid function or declaration
test.pwn(1631) : error 010: invalid function or declaration
test.pwn(1653) : warning 219: local variable "id" shadows a variable at a preceding level
test.pwn(1668) : warning 219: local variable "id" shadows a variable at a preceding level
test.pwn(1696) : warning 219: local variable "id" shadows a variable at a preceding level
test.pwn(1789) : warning 203: symbol is never used: "Angle"
test.pwn(1789) : warning 203: symbol is never used: "X"
test.pwn(1789) : warning 203: symbol is never used: "Y"
test.pwn(1789) : warning 203: symbol is never used: "Z"
test.pwn(1789) : warning 203: symbol is never used: "id"

If i remove the script, i get no errors.
So it's the brackets fault, but i've tried different ways and no luck..

AnonMKD
28/09/2013, 04:29 PM
CMD:slenderkidnap(playerid,params[])
{
{
if((GetPlayerScore(playerid) > 150) return SendClientMessage(playerid, COLOR_NAVY, "You need 150 score to be the SlenderMan"); //If the player has less than 150 score, he will get this message
return 1;
}
new Float:X,Float:Y,Float:Z,Float:Angle
new id;
if (sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /slenderkidnap [id]"); //if the ID isn't added, then it will show the usage.
if(!IsPlayerConnected(targetid) || targetid == playerid) return SendClientMessage(playerid, COLOR_ORANGE, "This player is offline, or you're trying to kidnap yourself."); //If the player ID isn't "valid".
if(!IsPlayerInRangeOfPoint(playerid,5,X,Y,Z); //if Slenderman is too far from the player (I bet i've failed here)
{
SendClientMessage(playerid, COLOR_RED, "You're too far from the target!");
}
if(IsPlayerInRangeOfPoint(playerid,5,X,Y,Z); //If he is in the range of the player, then the following things will happen.
{
SendClientMessage(id, COLOR_NAVY, "You've got kidnapped!"); //Kidnapped will get this.
SetPlayerInterior(id, 1); //His interior will be set to the meat factory
SetPlayerPos(id, 963.418762,2108.292480,1011.030273); //And the pos.
}
return 1;
}
try this

Konstantinos
28/09/2013, 04:35 PM
You messed it up a bit with the brace so the rest of the code was out of the command and never use a semicolon (; ) in if statement.

CMD:slenderkidnap(playerid,params[])
{
if((GetPlayerScore(playerid) > 150) return SendClientMessage(playerid, COLOR_NAVY, "You need 150 score to be the SlenderMan"); //If the player has less than 150 score, he will get this message
new id;
if (sscanf(params, "u", id)) return SendClientMessage(playerid, COLOR_ORANGE, "USAGE: /slenderkidnap [id]"); //if the ID isn't added, then it will show the usage.
if(!IsPlayerConnected(targetid) || targetid == playerid) return SendClientMessage(playerid, COLOR_ORANGE, "This player is offline, or you're trying to kidnap yourself."); //If the player ID isn't "valid".
new Float:XX,Float:YY,Float:ZZ;
GetPlayerPos(id, XX, YY, ZZ);
if(!IsPlayerInRangeOfPoint(playerid,5,XX, YY, ZZ)) return SendClientMessage(playerid, COLOR_RED, "You're too far from the target!");
else
{
SendClientMessage(id, COLOR_NAVY, "You've got kidnapped!"); //Kidnapped will get this.
SetPlayerInterior(id, 1); //His interior will be set to the meat factory
SetPlayerPos(id, 963.418762,2108.292480,1011.030273); //And the pos.
}
return 1;
}

Kyance
28/09/2013, 04:42 PM
----
Thanks Konstantinos.
Will +rep you both as soon as i can :p