SA-MP Forums Archive
health test problem - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: health test problem (/showthread.php?tid=149392)



health test problem - chaosnz - 22.05.2010

I had a go at coding a health test but im having a little trouble with it. It compiles no problem but it somehow blocks other commands in my game mode from working. Can someone please take a look at it and see why it blocks commands. Thanks to anyone who can help.


Heres the code.

Quote:

if(strcmp(cmd, "/test", true)==0)
{

if(IsPlayerLAdmin(playerid))
{
tmp = strtok(cmdtext, idx);

if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /test [ID]");
return 1;
}
new pid = strval(tmp);

if (IsPlayerConnected(pid))
{
storeint[pid] = GetPlayerInterior(playerid);
GetPlayerPos(pid, Floattorex[playerid], Floattorey[playerid], Floattorez[playerid]);
SetPlayerPos(pid,-1128.5248,835.2584,3.077;
SetPlayerHealth(pid,10);
OldHealth = GetPlayerHealth(pid,Health);
TogglePlayerControllable(pid,0);
BeingTested[pid] = 1;
SetTimer("HealthTest", 6000, 0);
return 1;
}
}
return 1;
}

Quote:

forward HealthTest();
public HealthTest()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(BeingTested[i] == 1)
{
BeingTested[i] = 0;
GetPlayerHealth(i,Health);
if(Health > OldHealth)
{
new string [256];
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
format(string, sizeof(string), "%s was kicked due to health cheats", pName);
SendClientMessageToAll(0x33CCFFAA, string);
Kick(i);
SaveToFile("KickLog",string);
}
else if(Health == OldHealth)
{
new string [256];
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
format(string, sizeof(string), "%s is not cheating.", pName);
SendClientMessageToAll(0x33CCFFAA, string);
SetPlayerHealth(i,100);
SetPlayerInterior(i, storeint[i]);
DOO_SetPlayerPos(i, storex[i],storey[i],storez[i]);
TogglePlayerControllable(i,1);
}
}
}
}
return 1;




Re: health test problem - Hiddos - 22.05.2010

Have you got any 'Unreachable code' warnings?


Re: health test problem - chaosnz - 23.05.2010

nope i get no errors what so ever when compiling


Re: health test problem - coole210 - 23.05.2010

lol wdf why would you tell everyone (that includes the person) that he wasn't cheating? He would be wondering why you checked him for cheats.

Health has to be a float too

Код:
new Float:Health[MAX_PLAYERS];



Re: health test problem - chaosnz - 23.05.2010

yeah ive got the health float at the top of my gamemode. And really the only reason i have the "was kicked for health cheats" and the "is not cheating" is incase anyone blames them of cheating. And or to "shame" the cheater.