Health returns 100..
#1

Код:
dcmd_farton(playerid,params[])
{
	new tmp2[300],tmp[300], Index;
  tmp = strtok(params,Index), tmp2 = strtok(params,Index);
	new id = strval(tmp);
	if(IsPlayerAdminLevel(playerid,2))
	{
	if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"That Player Is Not Connected");
	new string2[156], pname[24], pname2[24];
	GetPlayerName(playerid, pname, 24);
	GetPlayerName(id, pname2, 24);
	new Float:health;
	GetPlayerHealth(id,health);
	SetPlayerHealth(id,health - 5);
	format(string2, sizeof(string2), "Admin %s farted on %s (%d Health Left)",pname,pname2,floatround(health));
	SendClientMessageToAll(COLOR_RED,string2);
	}
	else
	{
	SendClientMessage(playerid,COLOR_RED,"You must be Admin Level 2 to do this.");
	}

	return 1;
}
the first time an admin uses this command, it always shows 100 health.. then the second time it starts taking away health.
Reply
#2

Try getting the health value afterwards or making a different variable.

Reply
#3

Try This:

pawn Код:
dcmd_farton(playerid,params[])
{
    new tmp2[300],tmp[300], Index;
  tmp = strtok(params,Index), tmp2 = strtok(params,Index);
    new id = strval(tmp);
    if(IsPlayerAdminLevel(playerid,2))
    {
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"That Player Is Not Connected");
    new string2[156], pname[24], pname2[24];
    GetPlayerName(playerid, pname, 24);
    GetPlayerName(id, pname2, 24);
    new Float:health;
    GetPlayerHealth(id,health);
    health -= 5; // Put this, so the variable will change. And not only return the new variable value if you do -5.
    SetPlayerHealth(id,health);
    format(string2, sizeof(string2), "Admin %s farted on %s (%d Health Left)",pname,pname2,floatround(health));
    SendClientMessageToAll(COLOR_RED,string2);
    }
    else
    {
    SendClientMessage(playerid,COLOR_RED,"You must be Admin Level 2 to do this.");
    }

    return 1;
}

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)