Help with timers
#1

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?
Reply
#2

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

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
Reply
#4

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

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 ?
Reply
#6

Yes, change
pawn Код:
if(PlayerInfo[i][pAdminLevel] >= 1)
in
pawn Код:
if(PlayerInfo[i][pTeam] == TEAM_COPS)
or whatever you're using to define cops.
Reply
#7

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)