SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 05/06/2010, 06:06 PM   #1
MWF2
Huge Clucker
 
MWF2's Avatar
 
Join Date: May 2010
Posts: 388
Reputation: 0
Default resetplayerweapons problem

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 Code:
forward JailedResetWeapons();

SetTimer("JailedResetWeapons",1000,1);

public JailedResetWeapons()
{
  for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(Jailed[i] == 1)
    {
    ResetPlayerWeapons(i);
    }
}
}
MWF2 is offline  
Old 05/06/2010, 06:14 PM   #2
DeathOnaStick
High-roller
 
DeathOnaStick's Avatar
 
Join Date: May 2009
Location: 127.0.0.1
Posts: 1,081
Reputation: 24
Default Re: resetplayerweapons problem

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 Code:
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.
__________________
If this helps you, please thank me by giving me reputation points
DeathOnaStick is offline  
Old 05/06/2010, 06:18 PM   #3
LTomi
Big Clucker
 
Join Date: Jan 2009
Posts: 115
Reputation: 0
Default Re: resetplayerweapons problem

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 Code:
public OnPlayerUpdate(playerid)
{
   if(Jailed[playerid] == 1)
   {
     ResetPlayerWeapons(playerid);
   }
   return 1;
}
LTomi is offline  
Old 05/06/2010, 06:26 PM   #4
MWF2
Huge Clucker
 
MWF2's Avatar
 
Join Date: May 2010
Posts: 388
Reputation: 0
Default Re: resetplayerweapons problem

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 Code:
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 Code:
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?
MWF2 is offline  
Old 05/06/2010, 06:30 PM   #5
LTomi
Big Clucker
 
Join Date: Jan 2009
Posts: 115
Reputation: 0
Default Re: resetplayerweapons problem

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.
LTomi is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I fixed the launching GTASA problem! Now the problem is in SAMP! HELP! Moustafa Client Support 24 16/09/2012 03:01 AM
ResetPlayerWeapons не отбирает оружее) Serafim_sd Русский/Russian 24 07/07/2011 06:39 AM
ResetPlayerWeapons for only one weapon a-day Help Archive 2 13/10/2009 01:13 PM
Resetplayerweapons in area.. Khelif Help Archive 1 12/07/2009 09:21 AM
ResetPlayerWeapons + GetPlayerWeaponData = slow update? Redirect Left Help Archive 0 20/04/2009 05:11 AM


All times are GMT. The time now is 08:21 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.