Problem with setting health
#1

So I've made a /shop dialog, and I made the option that players can buy +25 health, +50 health... so I made this, but it gives me warnings.

pawn Code:
case 5:
        {
            if(!response) return 0;
            if(response)
            {
                if(listitem == 0)
                {
                    new Float:health = GetPlayerHealth(playerid) + 25;
                    SetPlayerHealth(playerid, health);
                    GivePlayerMoney(playerid, -500);
                }
                if(listitem == 1)
                {
                    new Float:health = GetPlayerHealth(playerid) + 50;
                    SetPlayerHealth(playerid, health);
                    GivePlayerMoney(playerid, -1000);
                }
                if(listitem == 2)
                {
                    new Float:health = GetPlayerHealth(playerid) + 75;
                    SetPlayerHealth(playerid, health);
                    GivePlayerMoney(playerid, -1500);
                }
                if(listitem == 3)
                {
                    SetPlayerHealth(playerid, 100);
                    GivePlayerMoney(playerid, -2000);
                }
            }
        }
Warnings:

Code:
C:\Program Files\GTA San Andreas (2)\server\Basic Roleplay\gamemodes\Unfinished2.pwn(777) : warning 202: number of arguments does not match definition
C:\Program Files\GTA San Andreas (2)\server\Basic Roleplay\gamemodes\Unfinished2.pwn(783) : warning 202: number of arguments does not match definition
C:\Program Files\GTA San Andreas (2)\server\Basic Roleplay\gamemodes\Unfinished2.pwn(789) : warning 202: number of arguments does not match definition
EDIT: forgot to say what is causing the warnings lol, these lines are causing it:

pawn Code:
new Float:health = GetPlayerHealth(playerid) + 25;
new Float:health = GetPlayerHealth(playerid) + 50;
new Float:health = GetPlayerHealth(playerid) + 75;
Anybody knows how to fix this?
Reply
#2

GetPlayerHealth returns health of a player via reference

Use GetPlayerHealth(playerid, health); then health + 25;
Reply
#3

So like this?

pawn Code:
new Float:health = GetPlayerHealth(playerid, health)
                    SetPlayerHealth(playerid, health + 25);
EDIT: It compiled with no errors, going to test it now.
Reply
#4

Check the wiki if you dont know who to use a native

https://sampwiki.blast.hk/wiki/GetPlayerHealth
Reply
#5

Fixed it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)