SA-MP Forums Archive
If Else Question - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: If Else Question (/showthread.php?tid=432476)



If Else Question - RCS - 22.04.2013

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;
	}



Re: If Else Question - BigGroter - 22.04.2013

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.


Re: If Else Question - thefatshizms - 22.04.2013

edit: nvm


Re: If Else Question - RCS - 22.04.2013

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

397 line is "else"

EDIT: what? You have to indent it though.


Re: If Else Question - BittleRyan - 22.04.2013

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.


Re: If Else Question - RCS - 22.04.2013

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


Re: If Else Question - PT - 22.04.2013

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


Re: If Else Question - BigGroter - 22.04.2013

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".


Re: If Else Question - RCS - 22.04.2013

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