Help with timers - 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: Help with timers (
/showthread.php?tid=198447)
Help with timers -
[JnA]DukeNukem - 12.12.2010
Ok guys, this is it.... I admit that i have no idea how to use timers, and the time has come for me to need them...
so any help?
How can i make a command that when a player get's away from another player(me) he freezes?
Re: Help with timers -
Alex_Valde - 12.12.2010
I think you don't need timer for that.
You can use something simple like:
IsPlayerInRangeOfPoint- Store you position in Floats(X,Y,Z) and than see where is player, if he's more than let's say 20 meters away from you, you can freeze him.
This should be your base code and if you want something more than you can use timers, but I really think that you don't need timers for that. You'll only complicate the process and you'll have more work.
It's only my opinion.
Re: Help with timers -
[JnA]DukeNukem - 12.12.2010
I wan't the player to freeze automaticaly like if he is surrendered, if he get's away from point he freezes, without me doing some command
Re: Help with timers -
SkizzoTrick - 12.12.2010
pawn Код:
public OnPlayerSpawn(...)
{
SetTimer("AdminCheck",5000,1);
return 1;
}
forward AdminCheck(playerid);
public AdminCheck(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pAdminLevel] >= 1)
{
new Float:x,Float:y,Float:z;
new Float:pz,Float:py,Float:pz;
GetPlayerPos(i, x, y, z);
GetPlayerPos(playerid, px, py, pz);
if(!IsPlayerInRangeOfPoint(playerid,x,y,z))
{
TogglePlayerControllable(playerid, 0);
SendClientMessage(playerid,COLOR_RED,"You have freezed because you are not near admin");
}
}
}
return 1;
}
Didn't test it yet,but i guess it's working
EDIT:Changed to freeze,old one would kill the player
Re: Help with timers -
[JnA]DukeNukem - 12.12.2010
Quote:
Originally Posted by SkizzoTrick
pawn Код:
public OnPlayerSpawn(...) { SetTimer("AdminCheck",5000,1); return 1; }
forward AdminCheck(playerid); public AdminCheck(playerid) { for(new i = 0; i < MAX_PLAYERS; i++) { if(PlayerInfo[i][pAdminLevel] >= 1) { new Float:x,Float:y,Float:z; new Float:pz,Float:py,Float:pz; GetPlayerPos(i, x, y, z); GetPlayerPos(playerid, px, py, pz); if(!IsPlayerInRangeOfPoint(playerid,x,y,z)) { TogglePlayerControllable(playerid, 0); SendClientMessage(playerid,COLOR_RED,"You have freezed because you are not near admin"); } } } return 1; }
Didn't test it yet,but i guess it's working
EDIT:Changed to freeze,old one would kill the player
|
so if i want it to work for cops i just edit it to if is player cop or smthing ?
Re: Help with timers -
Marcel - 12.12.2010
Yes, change
pawn Код:
if(PlayerInfo[i][pAdminLevel] >= 1)
in
pawn Код:
if(PlayerInfo[i][pTeam] == TEAM_COPS)
or whatever you're using to define cops.
Re: Help with timers -
[JnA]DukeNukem - 12.12.2010
Thanks