Problem with setting health - 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: Problem with setting health (
/showthread.php?tid=414685)
Problem with setting health -
Da_Noob - 10.02.2013
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?
Re: Problem with setting health -
ReVo_ - 10.02.2013
GetPlayerHealth returns health of a player via reference
Use GetPlayerHealth(playerid, health); then health + 25;
Re: Problem with setting health -
Da_Noob - 10.02.2013
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.
AW: Re: Problem with setting health -
Nero_3D - 10.02.2013
Check the wiki if you dont know who to use a native
https://sampwiki.blast.hk/wiki/GetPlayerHealth
Re: Problem with setting health -
Da_Noob - 10.02.2013
Fixed it.