Ahojte. Mňa napadlo si spraviť príkaz /acheat ktorý by hráčovi nastavil život na 80 a potom by ho to skontrolovalo či má 80 hp a keď áno tak by to napísalo že nemá nesmrtelnosť a naopak. Ale mne to nastaví za 1 sekundu 80 života a za 3 sekundy mi to napíše že mám nesprtelnosť ale pritom nemám ale keď dám druhý raz tak to už napíše že nemám nesmrtelnosť.
Tu je kód.
#include <a_samp>
#include <sscanf>
#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(acheat,6,cmdtext);
return 0;
}
dcmd_acheat(playerid, params[])
{
new id,Float:health;
if(sscanf(params,"d",id)) return SendClientMessage(playerid,-1,"Použitie : /acheat [ ID ]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Hráč nieje pripojený!");
SetTimerEx("zivot", 1000, false, "i", playerid);
GetPlayerHealth(playerid,health);
if (health == 80)
{
SetTimerEx("nema", 3000, false, "i", playerid);
}
else if (health != 80)
{
SetTimerEx("ma", 3000, false, "i", playerid);
}
return 1;
}
forward ma(i);
public ma(i)
{
SendClientMessageToAll(-1,"Hráč ma nesmrtelnost!");
return 1;
}
forward nema(i);
public nema(i)
{
SendClientMessageToAll(-1,"Hráč nema nesmrtelnost!");
return 1;
}
forward zivot(i);
public zivot(i)
{
SetPlayerHealth(i,80);
return 1;
}
Ďakujem.