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

Pages: 1 2 3


Re: SetDisabledWeapons() - [eLg]Timmy - 10.09.2009

Even easier

At the top of script
pawn Код:
new CurrentWeapon[MAX_PLAYERS];
pawn Код:
public OnPlayerUpdate(playerid)
{
  if(CurrentWeapon[playerid] != GetPlayerWeapon(playerid)) {
    OnPlayerWeaponChange(playerid, CurrentWeapon[playerid], GetPlayerWeapon(playerid));
    CurrentWeapon[playerid] = GetPlayerWeapon(playerid);
  }
}

stock OnPlayerWeaponChange(playerid, oldweapon, newweapon) {
  if(newweapon == WEAPONHERE) {
    //do whatever you want
  }
  return true;
}
I'm using such callbacks for my anti-cheat. Works perfectly (faster than timer).


Re: SetDisabledWeapons() - Calgon - 10.09.2009

Quote:
Originally Posted by TimmehBoy
Even easier

At the top of script
pawn Код:
new CurrentWeapon[MAX_PLAYERS];
pawn Код:
public OnPlayerUpdate(playerid)
{
  if(CurrentWeapon[playerid] != GetPlayerWeapon(playerid)) {
    OnPlayerWeaponChange(playerid, CurrentWeapon[playerid], GetPlayerWeapon(playerid));
    CurrentWeapon[playerid] = GetPlayerWeapon(playerid);
  }
}

stock OnPlayerWeaponChange(playerid, oldweapon, newweapon) {
  if(newweapon == WEAPONHERE) {
    //do whatever you want
  }
  return true;
}
I'm using such callbacks for my anti-cheat. Works perfectly (faster than timer).
And your system supports ONE weapon, so that's kind of stupid. My system blacklists a bunch of weapons and bans if a player has it.


Re: SetDisabledWeapons() - Sergei - 10.09.2009

It is checking if player is holding invalid weapon all the time. You can't use any weapon without putting it in active weapon slot, so why checking all 12 slots all the time if checkign active weapon slot is enough?


Re: SetDisabledWeapons() - [eLg]Timmy - 10.09.2009

Quote:
Originally Posted by Calgon
Quote:
Originally Posted by TimmehBoy
Even easier

At the top of script
pawn Код:
new CurrentWeapon[MAX_PLAYERS];
pawn Код:
public OnPlayerUpdate(playerid)
{
  if(CurrentWeapon[playerid] != GetPlayerWeapon(playerid)) {
    OnPlayerWeaponChange(playerid, CurrentWeapon[playerid], GetPlayerWeapon(playerid));
    CurrentWeapon[playerid] = GetPlayerWeapon(playerid);
  }
}

stock OnPlayerWeaponChange(playerid, oldweapon, newweapon) {
  if(newweapon == WEAPONHERE) {
    //do whatever you want
  }
  return true;
}
I'm using such callbacks for my anti-cheat. Works perfectly (faster than timer).
And your system supports ONE weapon, so that's kind of stupid. My system blacklists a bunch of weapons and bans if a player has it.
If you would have a look at my snippet you would notice that it works. Cause the "OnPlayerWeaponChange" callback gets called everytime a player gets a new weapon. Simply do this:

pawn Код:
if(newweapon == WEP1 || newweapon == WEP2...)
and so on

Seriously think before you post.


Re: SetDisabledWeapons() - lavamike - 11.09.2009

Quote:
Originally Posted by Calgon
Quote:
Originally Posted by TimmehBoy
Even easier

At the top of script
pawn Код:
new CurrentWeapon[MAX_PLAYERS];
pawn Код:
public OnPlayerUpdate(playerid)
{
  if(CurrentWeapon[playerid] != GetPlayerWeapon(playerid)) {
    OnPlayerWeaponChange(playerid, CurrentWeapon[playerid], GetPlayerWeapon(playerid));
    CurrentWeapon[playerid] = GetPlayerWeapon(playerid);
  }
}

stock OnPlayerWeaponChange(playerid, oldweapon, newweapon) {
  if(newweapon == WEAPONHERE) {
    //do whatever you want
  }
  return true;
}
I'm using such callbacks for my anti-cheat. Works perfectly (faster than timer).
And your system supports ONE weapon, so that's kind of stupid. My system blacklists a bunch of weapons and bans if a player has it.
So just use the same method you did...

pawn Код:
switch(newweapon)
{
  case 1,2:
  {
    // Stuff here
  }
}



Re: SetDisabledWeapons() - Calgon - 11.09.2009

Quote:
Originally Posted by Lavamike
Quote:
Originally Posted by Calgon
Quote:
Originally Posted by TimmehBoy
Even easier

At the top of script
pawn Код:
new CurrentWeapon[MAX_PLAYERS];
pawn Код:
public OnPlayerUpdate(playerid)
{
  if(CurrentWeapon[playerid] != GetPlayerWeapon(playerid)) {
    OnPlayerWeaponChange(playerid, CurrentWeapon[playerid], GetPlayerWeapon(playerid));
    CurrentWeapon[playerid] = GetPlayerWeapon(playerid);
  }
}

stock OnPlayerWeaponChange(playerid, oldweapon, newweapon) {
  if(newweapon == WEAPONHERE) {
    //do whatever you want
  }
  return true;
}
I'm using such callbacks for my anti-cheat. Works perfectly (faster than timer).
And your system supports ONE weapon, so that's kind of stupid. My system blacklists a bunch of weapons and bans if a player has it.
So just use the same method you did...

pawn Код:
switch(newweapon)
{
  case 1,2:
  {
    // Stuff here
  }
}
I was correcting him and pointing out something. And I am using mine, learn how actually evaluate sentences.


Re: SetDisabledWeapons() - [eLg]Timmy - 11.09.2009

Quote:
Originally Posted by Calgon
Quote:
Originally Posted by Lavamike
Quote:
Originally Posted by Calgon
Quote:
Originally Posted by TimmehBoy
Even easier

At the top of script
pawn Код:
new CurrentWeapon[MAX_PLAYERS];
pawn Код:
public OnPlayerUpdate(playerid)
{
  if(CurrentWeapon[playerid] != GetPlayerWeapon(playerid)) {
    OnPlayerWeaponChange(playerid, CurrentWeapon[playerid], GetPlayerWeapon(playerid));
    CurrentWeapon[playerid] = GetPlayerWeapon(playerid);
  }
}

stock OnPlayerWeaponChange(playerid, oldweapon, newweapon) {
  if(newweapon == WEAPONHERE) {
    //do whatever you want
  }
  return true;
}
I'm using such callbacks for my anti-cheat. Works perfectly (faster than timer).
And your system supports ONE weapon, so that's kind of stupid. My system blacklists a bunch of weapons and bans if a player has it.
So just use the same method you did...

pawn Код:
switch(newweapon)
{
  case 1,2:
  {
    // Stuff here
  }
}
I was correcting him and pointing out something. And I am using mine, learn how actually evaluate sentences.
You didn't point out anything.


Re: SetDisabledWeapons() - Calgon - 12.09.2009

Quote:
Originally Posted by TimmehBoy
Quote:
Originally Posted by Calgon
Quote:
Originally Posted by Lavamike
Quote:
Originally Posted by Calgon
Quote:
Originally Posted by TimmehBoy
Even easier

At the top of script
pawn Код:
new CurrentWeapon[MAX_PLAYERS];
pawn Код:
public OnPlayerUpdate(playerid)
{
  if(CurrentWeapon[playerid] != GetPlayerWeapon(playerid)) {
    OnPlayerWeaponChange(playerid, CurrentWeapon[playerid], GetPlayerWeapon(playerid));
    CurrentWeapon[playerid] = GetPlayerWeapon(playerid);
  }
}

stock OnPlayerWeaponChange(playerid, oldweapon, newweapon) {
  if(newweapon == WEAPONHERE) {
    //do whatever you want
  }
  return true;
}
I'm using such callbacks for my anti-cheat. Works perfectly (faster than timer).
And your system supports ONE weapon, so that's kind of stupid. My system blacklists a bunch of weapons and bans if a player has it.
So just use the same method you did...

pawn Код:
switch(newweapon)
{
  case 1,2:
  {
    // Stuff here
  }
}
I was correcting him and pointing out something. And I am using mine, learn how actually evaluate sentences.
You didn't point out anything.
"
And your system supports ONE weapon, so that's kind of stupid. My system blacklists a bunch of weapons and bans if a player has it."


Re: SetDisabledWeapons() - [eLg]Timmy - 12.09.2009

Quote:
Originally Posted by Calgon
Quote:
Originally Posted by TimmehBoy
Quote:
Originally Posted by Calgon
Quote:
Originally Posted by Lavamike
Quote:
Originally Posted by Calgon
Quote:
Originally Posted by TimmehBoy
Even easier

At the top of script
pawn Код:
new CurrentWeapon[MAX_PLAYERS];
pawn Код:
public OnPlayerUpdate(playerid)
{
  if(CurrentWeapon[playerid] != GetPlayerWeapon(playerid)) {
    OnPlayerWeaponChange(playerid, CurrentWeapon[playerid], GetPlayerWeapon(playerid));
    CurrentWeapon[playerid] = GetPlayerWeapon(playerid);
  }
}

stock OnPlayerWeaponChange(playerid, oldweapon, newweapon) {
  if(newweapon == WEAPONHERE) {
    //do whatever you want
  }
  return true;
}
I'm using such callbacks for my anti-cheat. Works perfectly (faster than timer).
And your system supports ONE weapon, so that's kind of stupid. My system blacklists a bunch of weapons and bans if a player has it.
So just use the same method you did...

pawn Код:
switch(newweapon)
{
  case 1,2:
  {
    // Stuff here
  }
}
I was correcting him and pointing out something. And I am using mine, learn how actually evaluate sentences.
You didn't point out anything.
"
And your system supports ONE weapon, so that's kind of stupid. My system blacklists a bunch of weapons and bans if a player has it."
Mine too... the only thing you have to do is e.g.
pawn Код:
switch(newweapon)
{
  case 1,2:
  {
  }
}
like lavamike already mentioned.

READ the CODE before YOU REPLY.


Re: SetDisabledWeapons() - Calgon - 12.09.2009

Quote:
Originally Posted by TimmehBoy
Quote:
Originally Posted by Calgon
Quote:
Originally Posted by TimmehBoy
Quote:
Originally Posted by Calgon
Quote:
Originally Posted by Lavamike
Quote:
Originally Posted by Calgon
Quote:
Originally Posted by TimmehBoy
Even easier

At the top of script
pawn Код:
new CurrentWeapon[MAX_PLAYERS];
pawn Код:
public OnPlayerUpdate(playerid)
{
  if(CurrentWeapon[playerid] != GetPlayerWeapon(playerid)) {
    OnPlayerWeaponChange(playerid, CurrentWeapon[playerid], GetPlayerWeapon(playerid));
    CurrentWeapon[playerid] = GetPlayerWeapon(playerid);
  }
}

stock OnPlayerWeaponChange(playerid, oldweapon, newweapon) {
  if(newweapon == WEAPONHERE) {
    //do whatever you want
  }
  return true;
}
I'm using such callbacks for my anti-cheat. Works perfectly (faster than timer).
And your system supports ONE weapon, so that's kind of stupid. My system blacklists a bunch of weapons and bans if a player has it.
So just use the same method you did...

pawn Код:
switch(newweapon)
{
  case 1,2:
  {
    // Stuff here
  }
}
I was correcting him and pointing out something. And I am using mine, learn how actually evaluate sentences.
You didn't point out anything.
"
And your system supports ONE weapon, so that's kind of stupid. My system blacklists a bunch of weapons and bans if a player has it."
Mine too... the only thing you have to do is e.g.
pawn Код:
switch(newweapon)
{
  case 1,2:
  {
  }
}
like lavamike already mentioned.

READ the CODE before YOU REPLY.
Whatever, I've been up for less than 10 minutes. But anyway, I still think my method is a lot better, seeing as yours is practically always cycling the same code, where as mine is ran a little slower, and not only that, I don't use OnPlayerUpdate anywhere in my script, I'm not keen on using it either.


Re: SetDisabledWeapons() - Daem - 12.09.2009

pawn Код:
new keys, updown, leftright;
new weap; //wat ever
new Float:P[3];


stock SetDisabledWeapon(weaponid) //it's not like SetDisabledWeapons - notice the 's'!
{
weap = GetPlayerWeapon(weaponid);
if(weap == weaponid)
{
GetPlayerKeys(playerid, keys, updown, leftright);
if(keys == KEY_FIRE)
{
GetPlayerPos(playerid, P[0], P[1], P[2]);
SetPlayerPos(playerid, P[0], P[1], P[2]+ 0.0001);
}} return true; }
;)


Re: SetDisabledWeapons() - [eLg]Timmy - 12.09.2009

Quote:
Originally Posted by Daem
pawn Код:
new keys, updown, leftright;
new weap; //wat ever
new Float:P[3];


stock SetDisabledWeapon(weaponid) //it's not like SetDisabledWeapons - notice the 's'!
{
weap = GetPlayerWeapon(weaponid);
if(weap == weaponid)
{
GetPlayerKeys(playerid, keys, updown, leftright);
if(keys == KEY_FIRE)
{
GetPlayerPos(playerid, P[0], P[1], P[2]);
SetPlayerPos(playerid, P[0], P[1], P[2]+ 0.0001);
}} return true; }
How should that work. Please relook at your code :S


Re: SetDisabledWeapons() - Correlli - 12.09.2009

Quote:
Originally Posted by Seif_ [adream-rp.com
]
Just use my released include instead of posting irrelevant codes
As someone else pointed in your topic:
Quote:
Originally Posted by Joe Staff
Since you're removing the disabled weapon, what would be the point of returning 0 on OnPlayerUpdate? If a person is hacking for weapons, his weapons can't be removed by scripting. Which means he'll now be invisible to other players until he switches weapons.



Re: SetDisabledWeapons() - Daem - 13.09.2009

Quote:
Originally Posted by TimmehBoy
How should that work. Please relook at your code :S
make a timer for this/put it in OnPlayerUpdate
look again

GetPlayerPos(playerid, P[0], P[1], P[2]);
SetPlayerPos(playerid, P[0], P[1], P[2]+ 0.0001);


Re: SetDisabledWeapons() - Sergei - 13.09.2009

Quote:
Originally Posted by Daem
Quote:
Originally Posted by TimmehBoy
How should that work. Please relook at your code :S
make a timer for this/put it in OnPlayerUpdate
look again

GetPlayerPos(playerid, P[0], P[1], P[2]);
SetPlayerPos(playerid, P[0], P[1], P[2]+ 0.0001);
Weapon will already be fired before server will manage to process your code. It's logical that client can process things faster itself than server.


Re: SetDisabledWeapons() - [eLg]Timmy - 13.09.2009

Quote:
Originally Posted by Daem
pawn Код:
new keys, updown, leftright;
new weap; //wat ever
new Float:P[3];


stock SetDisabledWeapon(weaponid) //it's not like SetDisabledWeapons - notice the 's'!
{
weap = GetPlayerWeapon(weaponid);
if(weap == weaponid)
{
GetPlayerKeys(playerid, keys, updown, leftright);
if(keys == KEY_FIRE)
{
GetPlayerPos(playerid, P[0], P[1], P[2]);
SetPlayerPos(playerid, P[0], P[1], P[2]+ 0.0001);
}} return true; }
It wont work...there is no playerid parameter at all. Nothing...

Look at e.g.
pawn Код:
GetPlayerWeapon(weaponid)
Are you serious?
And WHERE in your code is playerid Think before you post..


Re: SetDisabledWeapons() - Daem - 13.09.2009

Quote:
Originally Posted by TimmehBoy
Quote:
Originally Posted by Daem
pawn Код:
new keys, updown, leftright;
new weap; //wat ever
new Float:P[3];


stock SetDisabledWeapon(weaponid) //it's not like SetDisabledWeapons - notice the 's'!
{
weap = GetPlayerWeapon(weaponid);
if(weap == weaponid)
{
GetPlayerKeys(playerid, keys, updown, leftright);
if(keys == KEY_FIRE)
{
GetPlayerPos(playerid, P[0], P[1], P[2]);
SetPlayerPos(playerid, P[0], P[1], P[2]+ 0.0001);
}} return true; }
It wont work...there is no playerid parameter at all. Nothing...

Look at e.g.
pawn Код:
GetPlayerWeapon(weaponid)
Are you serious?
And WHERE in your code is playerid Think before you post..
pawn Код:
stock SetDisabledWeapon(playerid, weaponid) //it's not like SetDisabledWeapons - notice the 's'!
{
weap = GetPlayerWeapon(weaponid);
if(weap == weaponid)
{
GetPlayerKeys(playerid, keys, updown, leftright);
if(keys == KEY_FIRE)
{
GetPlayerPos(playerid, P[0], P[1], P[2]);
SetPlayerPos(playerid, P[0], P[1], P[2]+ 0.0001);
}} return true; }
?


Re: SetDisabledWeapons() - Correlli - 13.09.2009

Learn how to use GetPlayerWeapon function.


Re: SetDisabledWeapons() - UsaBoy91 - 13.09.2009

I've made here a lil' code ... Maybe this will can help you

http://pastie.org/615565

or

http://pastebin.com/d22aa1c23