11.03.2013, 20:03
Here is my /god cmd code, i have put some // to help you get faster into my thinking.
Errors in lines: else if: "empty statement"
else return: invalid expression ,assumed zero
same line: warning: expression has no effect
same line: expected token: ";", but found "return"
return 1;: unreachable code.
Notice that if i put in /* --- */ the whole "else if" statement, the code gets sucessfully compiled. So there is something I do wrong in "else if" area. Of cource i have my includes in pawno and written upper in code, not here. Help!
pawn Код:
CMD:god(playerid, params[])
{
new str1[128], str2[128], str3[128], admin[MAX_PLAYER_NAME], p[MAX_PLAYER_NAME], id, Float: health;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "You must be Admin to use this command");//
if(sscanf(params, "d", id) && playerid==id) return SetPlayerHealth(playerid, 9999999999999999.0);//if you type /god, instead of getting message about correct usage, you trigger the command on yourself.
GetPlayerName(playerid, admin, MAX_PLAYER_NAME);
GetPlayerName(id, p, MAX_PLAYER_NAME);
GetPlayerHealth(id,health);
if(IsPlayerConnected(id) && health<101.0)
{
SetPlayerHealth(id, 9999999999999999.0);
format(str1, sizeof(str1), "Admin %s has turned you into god!", admin);
SendClientMessage(id, 0x00FF00AA, str1);
format(str2, sizeof(str2), "You have successfully turned %s into god.", p);
SendClientMessage(playerid, 0x00FF00AA, str2);
}
else if (IsPlayerConnected(id) && health>100.0);//
{ //
SetPlayerHealth(id, 100.0); // here, you get back to normal
format(str3, sizeof(str3), "Back to mortality.");//
SendClientMessage(playerid, 0x00FF00AA, str3);//
} //
else return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected.");
return 1;
}
else return: invalid expression ,assumed zero
same line: warning: expression has no effect
same line: expected token: ";", but found "return"
return 1;: unreachable code.
Notice that if i put in /* --- */ the whole "else if" statement, the code gets sucessfully compiled. So there is something I do wrong in "else if" area. Of cource i have my includes in pawno and written upper in code, not here. Help!