SA-MP Forums Archive
resetplayerweapons problem - 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: resetplayerweapons problem (/showthread.php?tid=152749)



resetplayerweapons problem - MWF2 - 05.06.2010

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);
    }
}
}



Re: resetplayerweapons problem - DeathOnaStick - 05.06.2010

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.


Re: resetplayerweapons problem - LTomi - 05.06.2010

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;
}



Re: resetplayerweapons problem - MWF2 - 05.06.2010

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?


Re: resetplayerweapons problem - LTomi - 05.06.2010

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.