PDA

View Full Version : how to fix this cmd its generating lots of errors


Zonoya
01/10/2011, 09:53 AM
hi guys i have this cmd to crash a player but i need to fix it its not working right can someone help me please here is the code:

CMD:Crash(playerid, params[])
{
new string[128];
if(pInfo[playerid][AdminLevel] >=4 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED,"ERROR: You need to be administrator to use this command!");
{
if(sscanf(params, "us[128]", params[0], params[1])) return SendClientMessage(playerid, RED,"USAGE: {FFFF00}/Crash [playerid] [reason]");

if ( IsPlayerConnected( params[ 0 ] ) && params[ 0 ] != INVALID_PLAYER_ID && params[ 0 ] != playerid )
{
if(!strlen(params[1]))
{
format(string, sizeof(string),"%s Has been crashed by Admin %s [no reason given]!",PlayerName2(params[0]),PlayerName2(playerid));
SendClientMessageToAll(ABLUE, string);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
} else {

format(string, sizeof(string),"%s has been crashed by Admin %s [Reason: %s]", PlayerName2(params[0]), PlayerName2(playerid), params[1]);
SendClientMessageToAll(ABLUE, string);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
} else {

SendClientMessage(playerid, RED,"ERROR Player Specified Not Online!");
}
return 1;
}
return 1;
}
}


Errors:

C:\DOCUME~1\Rhys\Desktop\SA8BEC~1\FILTER~1\Account .pwn(266) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


1 Error.



i dont know what the problem is line 266 is:) else (

can someone plz help me :|

=WoR=G4M3Ov3r
01/10/2011, 10:03 AM
CMD:Crash(playerid, params[])
{
new string[128];
if(pInfo[playerid][AdminLevel] >=4 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED,"ERROR: You need to be administrator to use this command!");
{
if(sscanf(params, "us[128]", params[0], params[1])) return SendClientMessage(playerid, RED,"USAGE: {FFFF00}/Crash [playerid] [reason]");

if ( IsPlayerConnected( params[ 0 ] ) && params[ 0 ] != INVALID_PLAYER_ID && params[ 0 ] != playerid )
{
if(!strlen(params[1]))
{
format(string, sizeof(string),"%s Has been crashed by Admin %s [no reason given]!",PlayerName2(params[0]),PlayerName2(playerid));
SendClientMessageToAll(ABLUE, string);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
}
else
{

format(string, sizeof(string),"%s has been crashed by Admin %s [Reason: %s]", PlayerName2(params[0]), PlayerName2(playerid), params[1]);
SendClientMessageToAll(ABLUE, string);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
GameTextForPlayer(params[0], "!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
}
else
{

SendClientMessage(playerid, RED,"ERROR Player Specified Not Online!");
}
return 1;
}
return 1;
}
}


Try it like this

Zonoya
01/10/2011, 10:11 AM
same error :|

Jafet_Macario
01/10/2011, 10:12 AM
CMD:Crash(playerid, params[])
{
new string[128], id, reason[50];
if(pInfo[playerid][AdminLevel] < 4 || !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED,"ERROR: You need to be administrator to use this command!");
if(sscanf(params, "us[128]", id, reason)) return SendClientMessage(playerid, RED,"USAGE: {FFFF00}/Crash [playerid] [reason]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, RED,"ERROR Player Specified is Offline");
if(id == playerid) return SendClientMessage(playerid, RED,"You can't crash yourself"); // Optional
if(!strlen(reason))
{
format(string, sizeof(string),"%s Has been crashed by Admin %s [no reason given]!",PlayerName2(id),PlayerName2(playerid));
SendClientMessageToAll(ABLUE, string);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
}
else
{
format(string, sizeof(string),"%s has been crashed by Admin %s [Reason: %s]", PlayerName2(id), PlayerName2(playerid), reason);
SendClientMessageToAll(ABLUE, string);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
GameTextForPlayer(id, "•!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
}
return 1;
}

Zonoya
01/10/2011, 10:13 AM
thx it works fine now :)

Vince
01/10/2011, 10:15 AM
Everyone in his right mind would see that
if{}
else{}
else{}
wouldn't work ...

Other than that, use variables! Using params[0] makes your code look messy.

Zonoya
01/10/2011, 10:34 AM
its fixed now anyway Vince lol