Posts: 6,129
Threads: 36
Joined: Jan 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.
Posts: 2,862
Threads: 11
Joined: Mar 2008
Reputation:
0
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?
Posts: 6,129
Threads: 36
Joined: Jan 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.
Posts: 6,129
Threads: 36
Joined: Jan 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."
Posts: 6,129
Threads: 36
Joined: Jan 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.