SA-MP Forums Archive
Invalid function - 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: Invalid function (/showthread.php?tid=393749)



Invalid function - Louris - 19.11.2012

Code:

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(DM[playerid] == true)
if(PlayerInfo[playerid][pVip] == 1)
GetPlayerHealth(killerid,health);
SetPlayerHealth(killerid,health + 50.0);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
			}
			else
			{
GetPlayerHealth(killerid,health);
SetPlayerHealth(killerid,health + 25.0);
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
}
Error: error 010: invalid function or declaration

Error line:

else


I want to make if player vip, he get +50 hp when he kill someone, if he doesn't vip, he get for kill only 25 HP.


Re: Invalid function - Ballu Miaa - 19.11.2012

Here bruh! You were required to declare a floating(decimal/fractions) variable and clear some code.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(PlayerInfo[playerid][pVip] >= 1)
    {
        new Float:health;
        GetPlayerHealth(killerid,health);
        SetPlayerHealth(killerid,health + 50.0);
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    }
    else
    {
        new Float:health;
        GetPlayerHealth(killerid,health);
        SetPlayerHealth(killerid,health + 25.0);
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    }
}



Re: Invalid function - Glad2BeHere - 19.11.2012

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(PlayerInfo[playerid][pVip] >= 1)
    {
        new Float:health;
        GetPlayerHealth(killerid,health);
        SetPlayerHealth(killerid,health + 50.0);
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    }
    else
    {
        new Float:health;
        GetPlayerHealth(killerid,health);
        SetPlayerHealth(killerid,health + 25.0);
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    }
    return 1;
}
forget return value


Re: Invalid function - Louris - 19.11.2012

Now i get these warnings:
Код:
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn(163) : warning 219: local variable "health" shadows a variable at a preceding level
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn(170) : warning 219: local variable "health" shadows a variable at a preceding level
C:\Users\Lauryno\Desktop\Servas\gamemodes\bom.pwn(528) : warning 203: symbol is never used: "health"



Re: Invalid function - Ballu Miaa - 19.11.2012

Try this one!

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(PlayerInfo[playerid][pVip] >= 1)
    {
        GetPlayerHealth(killerid,health);
        SetPlayerHealth(killerid,health + 50.0);
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    }
    else
    {
        GetPlayerHealth(killerid,health);
        SetPlayerHealth(killerid,health + 25.0);
        SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
    }
    return 1;
}



Re: Invalid function - Louris - 19.11.2012

Ballu, no warnings or errors, i test this script tomorrow, thanks


Re: Invalid function - Ballu Miaa - 19.11.2012

Quote:
Originally Posted by Louris
Посмотреть сообщение
Ballu, no warnings or errors, i test this script tomorrow, thanks
Cool! Not a problem.