SetDisabledWeapons()
#41

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).
Reply
#42

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

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

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

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
  }
}
Reply
#46

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

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

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."
Reply
#49

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

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

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; }
;)
Reply
#52

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

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

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);
Reply
#55

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

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

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; }
?
Reply
#58

Learn how to use GetPlayerWeapon function.
Reply
#59

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

http://pastie.org/615565

or

http://pastebin.com/d22aa1c23
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)