health test problem
#1

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;

Reply
#2

Have you got any 'Unreachable code' warnings?
Reply
#3

nope i get no errors what so ever when compiling
Reply
#4

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];
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)