SA-MP Forums Archive
Timers Dont work - 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: Timers Dont work (/showthread.php?tid=356727)



Timers Dont work - jtemple042996 - 04.07.2012

I have a player test by setting their HP to 100 but not their server sided value, and it doesnt send the mesasge to admins like its supposed to.
Код:
public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	SetTimer("chkhealth",60000,true);
	SetTimer("chkweapons",60000,true);
	SetTimer("chkarmour",60000,true);
	SetTimer("chkmoney",60000,true);
	SetTimer("chkskin",60000,true);
	return 1;
}
forward chkhealth();
public chkhealth()
{
	new astring[MAX_PLAYER_NAME+128],pname[MAX_PLAYER_NAME],Float:hp;
    for(new i = 0; i < MAX_PLAYERS; i++)
{
	if(IsPlayerConnected(i))
	{
	if(logged[i] == 1)
	{
	GetPlayerHealth(i,hp);
	if(hp != health[i])
	{
	format(astring,sizeof(astring),"%s(%i) is possibly health hacking, please investigate!",pname,i);
	SendClientMessageToAdmins(0xFF0000FF,astring);
	}
	}
	}
}
}
forward chkarmour();
public chkarmour()
{
	new astring[MAX_PLAYER_NAME+128],pname[MAX_PLAYER_NAME],Float:parmour;
    for(new i = 0; i < MAX_PLAYERS; i++)
{
	if(IsPlayerConnected(i))
	{
	if(logged[i] == 1)
	{
	GetPlayerArmour(i,parmour);
	if(parmour != armour[i])
	{
	format(astring,sizeof(astring),"%s(%i) is possibly armour hacking, please investigate!",pname,i);
	SendClientMessageToAdmins(0xFF0000FF,astring);
	}
	}
	}
}
}



Re: Timers Dont work - jtemple042996 - 06.07.2012

Anything??


Re: Timers Dont work - clarencecuzz - 06.07.2012

Could you please post your SendClientMessageToAdmins function for me?
There is something in there that is obviously not right.

Here is a small fix for some of your script:
pawn Код:
public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    SetTimer("chkhealth",60000,true);
    SetTimer("chkweapons",60000,true);
    SetTimer("chkarmour",60000,true);
    SetTimer("chkmoney",60000,true);
    SetTimer("chkskin",60000,true);
    return 1;
}

forward chkhealth();
public chkhealth()
{
    for(new i = 0; i < MAX_PLAYERS; i++) {
    if(IsPlayerConnected(i)) {
    if(logged[i] == 1) {
    new astring[MAX_PLAYER_NAME+54],pname[MAX_PLAYER_NAME],Float:hp;
    GetPlayerHealth(i,hp);
    if(hp != health[i]) {
    GetPlayerName(i, pname, MAX_PLAYER_NAME);
    format(astring,sizeof(astring),"%s(%i) is possibly health hacking, please investigate!",pname,i);
    SendClientMessageToAdmins(0xFF0000FF,astring);
    } } } }
    return 1;
}

forward chkarmour();
public chkarmour()
{
    for(new i = 0; i < MAX_PLAYERS; i++) {
    if(IsPlayerConnected(i)) {
    if(logged[i] == 1) {
    new astring[MAX_PLAYER_NAME+54], pname[MAX_PLAYER_NAME],Float:parmour;
    GetPlayerArmour(i,parmour);
    if(parmour != armour[i]) {
    GetPlayerName(i, pname, MAX_PLAYER_NAME);
    format(astring,sizeof(astring),"%s(%i) is possibly armour hacking, please investigate!",pname,i);
    SendClientMessageToAdmins(0xFF0000FF,astring);
    armour[i] = parmour;
    } } } }
    return 1;
}



Re: Timers Dont work - [KHK]Khalid - 06.07.2012

Add this after SendClientMessageToAdmins

pawn Код:
print("Suspected a health hacker");
if this message got printed in the server console and you still got no messages in-game then it's 99.9% your SendClientMessageToAdmins function is done wrongly then you'll have to show us it.

Uhm just asking why many timers when you can do all the checks with only one timer (More efficient ha?)?


Respuesta: Timers Dont work - Chris1337 - 06.07.2012

or maybe! is because you must use SetTimerEx instead of loop every player you already defined it on the timer


Re: Timers Dont work - jtemple042996 - 06.07.2012

Код:
	stock SendClientMessageToAdmins(color,message[])
{
	for (new i=0;i<MAX_PLAYERS;i++)
	{
    if (IsPlayerConnected(i))
    {
   	if (alevel[i] >= 1)
    {
    SendClientMessage(i,color,message);
    }
    }
	}
	return 1;
}



Re: Timers Dont work - clarencecuzz - 06.07.2012

Try:
pawn Код:
forward SendClientMessageToAdmins(color, const string[]);
public SendClientMessageToAdmins(color, const string[])
{
for(new i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i)) {
if(alevel[i] > 0) {
SendClientMessage(i, color, string);
} } }
return 1;
}



Re: Timers Dont work - [MM]RoXoR[FS] - 06.07.2012

SHow the code where you save health[i] and armor[i]