resetplayerweapons problem
#1

I want to make it so if a player is in jail, it resets there weapons over and over, so hackers cannot spawn weapons in jail.

I tested it, and for some reason, it allows the weapons to be used for a couple of seconds then it resets them

Is this a good efficient way?

pawn Код:
forward JailedResetWeapons();

SetTimer("JailedResetWeapons",1000,1);

public JailedResetWeapons()
{
  for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(Jailed[i] == 1)
    {
    ResetPlayerWeapons(i);
    }
}
}
Reply
#2

Quote:
Originally Posted by MWF2
I want to make it so if a player is in jail, it resets there weapons over and over, so hackers cannot spawn weapons in jail.

I tested it, and for some reason, it allows the weapons to be used for a couple of seconds then it resets them

Is this a good efficient way?

pawn Код:
forward JailedResetWeapons();

SetTimer("JailedResetWeapons",5000,1);

public JailedResetWeapons()
{
  for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(Jailed[i] == 1)
    {
    ResetPlayerWeapons(i);
    }
}
}
Ofcourse you can use the weapons for a couple of seconds. You made a timer of 5 seconds (5000ms) =P. If you want it to be changed, just change the timer-time.

Cheers.
Reply
#3

I think it is better to do with OnPlayerUpdate. It is called when the server's or the player's stats (including weapons) change, so you can remove the weapons immediately.

pawn Код:
public OnPlayerUpdate(playerid)
{
   if(Jailed[playerid] == 1)
   {
     ResetPlayerWeapons(playerid);
   }
   return 1;
}
Reply
#4

Quote:
Originally Posted by LTomi
I think it is better to do with OnPlayerUpdate. It is called when the server's or the player's stats (including weapons) change, so you can remove the weapons immediately.

pawn Код:
public OnPlayerUpdate(playerid)
{
   if(Jailed[playerid] == 1)
   {
     ResetPlayerWeapons(playerid);
   }
   return 1;
}
But isn't onplayerupdate the inefficient way or something....



Can you guys tell me, if the way i did it is a good way, reduce lag, etc.


I fixed the timer, now it's


pawn Код:
forward JailedResetWeapons();

SetTimer("JailedResetWeapons",5000,1);

public JailedResetWeapons()
{
  for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(Jailed[i] == 1)
    {
    ResetPlayerWeapons(i);
    }
}
}
It removes the weapons perfect, but is it good way of doing it?
Reply
#5

I think OnPlayerUpdate is better because it removes the weapon immediately and it doesn't make the server lag if you script simple operations into it as far as I know.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)