If Else Question
#1

Hi can u tell me where i is this error?
i made this command before, but i wanted to update it so admins can only use it.

Код:
\0.3b\filterscripts\RFS.pwn(398) : error 029: invalid expression, assumed zero
Код:
if (strcmp("/power", cmdtext, true, 10) == 0)
	{
        if(!IsPlayerAdmin(playerid)) return
		SetPlayerHealth(playerid, 250);
		SetPlayerArmour(playerid, 250);
		GivePlayerWeapon(playerid,30, 3000);
		GivePlayerWeapon(playerid,4, 1);
		GivePlayerWeapon(playerid,16, 3);
		GivePlayerWeapon(playerid,17, 3);
		GivePlayerWeapon(playerid,23, 250);
		GivePlayerWeapon(playerid,44, 1);
		GivePlayerWeapon(playerid,46, 1);
		SendClientMessage(playerid, purple, "Enjoy ;)))))");
		new string[52];
		GetPlayerName(playerid, string, MAX_PLAYER_NAME);
		format(string, sizeof string, "%s used the command /power", string);
		SendClientMessageToAll(ltblue, string);
		else
	{
		SendClientMessage(playerid, red, "WARNING: You need to be admin to use this command!");
	}
		return 1;
	}
Reply
#2

pawn Код:
if (strcmp("/power", cmdtext, true, 10) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
        SetPlayerHealth(playerid, 250);
        SetPlayerArmour(playerid, 250);
        GivePlayerWeapon(playerid,30, 3000);
        GivePlayerWeapon(playerid,4, 1);
        GivePlayerWeapon(playerid,16, 3);
        GivePlayerWeapon(playerid,17, 3);
        GivePlayerWeapon(playerid,23, 250);
        GivePlayerWeapon(playerid,44, 1);
        GivePlayerWeapon(playerid,46, 1);
        SendClientMessage(playerid, purple, "Enjoy ;)))))");
        new string[52];
        GetPlayerName(playerid, string, MAX_PLAYER_NAME);
        format(string, sizeof string, "%s used the command /power", string);
        SendClientMessageToAll(ltblue, string);
        }
    else
    {
        SendClientMessage(playerid, red, "WARNING: You need to be admin to use this command!");
    }
        return 1;
    }
Try this.
You have to indent it though.
Reply
#3

edit: nvm
Reply
#4

shows RFS.pwn(397) : error 029: invalid expression, assumed zero

397 line is "else"

EDIT: what? You have to indent it though.
Reply
#5

pawn Код:
if (strcmp("/power", cmdtext, true, 10) == 0)
{
    if(IsPlayerAdmin(playerid))
    {
        SetPlayerHealth(playerid, 250);
        SetPlayerArmour(playerid, 250);
        GivePlayerWeapon(playerid,30, 3000);
        GivePlayerWeapon(playerid,4, 1);
        GivePlayerWeapon(playerid,16, 3);
        GivePlayerWeapon(playerid,17, 3);
        GivePlayerWeapon(playerid,23, 250);
        GivePlayerWeapon(playerid,44, 1);
        GivePlayerWeapon(playerid,46, 1);
        SendClientMessage(playerid, purple, "Enjoy ;)))))");
        new string[52];
        GetPlayerName(playerid, string, MAX_PLAYER_NAME);
        format(string, sizeof string, "%s used the command /power", string);
        SendClientMessageToAll(ltblue, string);
    }
    else
    {
        SendClientMessage(playerid, red, "WARNING: You need to be admin to use this command!");
    }
        return 1;
}
Try that, not sure if indenting would cause an error like that.
Reply
#6

hehe thanks man its actually worked, idk how, i will review to find what was my mistake, btw you have rep+
Reply
#7

Hi

pawn Код:
if (strcmp("/power", cmdtext, true, 10) == 0)
{
    if(!IsPlayerAdmin(playerid))
    {
        SendClientMessage(playerid, red, "WARNING: You need to be admin to use this command!");
        return 1;
    }
    else
    {
        SetPlayerHealth(playerid, 250);
        SetPlayerArmour(playerid, 250);
        GivePlayerWeapon(playerid,30, 3000);
        GivePlayerWeapon(playerid,4, 1);
        GivePlayerWeapon(playerid,16, 3);
        GivePlayerWeapon(playerid,17, 3);
        GivePlayerWeapon(playerid,23, 250);
        GivePlayerWeapon(playerid,44, 1);
        GivePlayerWeapon(playerid,46, 1);
        SendClientMessage(playerid, purple, "Enjoy ;)))))");
        new PT[60];
        new PTname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, PT, MAX_PLAYER_NAME);
        format(PT, sizeof(PT), "%s (%d) used the command /power", PTname, playerid);
        SendClientMessageToAll(ltblue, PT);
        return 1;
    }
}
PT
Reply
#8

Quote:
Originally Posted by RCS
Посмотреть сообщение
shows RFS.pwn(397) : error 029: invalid expression, assumed zero

397 line is "else"

EDIT: what? You have to indent it though.
Add 4 spaces or a "tab".
Reply
#9

thanks PT, i appreciate that. , you have rep+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)