SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 11/07/2012, 03:24 PM   #671
Jancis71
Little Clucker
 
Join Date: Jun 2010
Posts: 1
Reputation: 0
Default Re: Useful Snippets

Get weapon model ID that can be used in pickups for example:

pawn Code:
GetWeaponModel(weaponid)
{
    switch(weaponid)
    {
        case WEAPON_BRASSKNUCKLE:       return 331;
        case WEAPON_GOLFCLUB:           return 333;
        case WEAPON_NITESTICK:          return 334;
        case WEAPON_KNIFE:              return 335;
        case WEAPON_BAT:                return 336;
        case WEAPON_SHOVEL:             return 337;
        case WEAPON_POOLSTICK:          return 338;
        case WEAPON_KATANA:             return 339;
        case WEAPON_CHAINSAW:           return 341;
        case WEAPON_DILDO:              return 321;
        case WEAPON_DILDO2:             return 322;
        case WEAPON_VIBRATOR:           return 323;
        case WEAPON_VIBRATOR2:          return 324;
        case WEAPON_FLOWER:             return 325;
        case WEAPON_CANE:               return 326;
        case WEAPON_GRENADE:            return 342;
        case WEAPON_TEARGAS:            return 343;
        case WEAPON_MOLTOV:             return 344;
        case WEAPON_COLT45:             return 346;
        case WEAPON_SILENCED:           return 347;
        case WEAPON_DEAGLE:             return 348;
        case WEAPON_SHOTGUN:            return 349;
        case WEAPON_SAWEDOFF:           return 350;
        case WEAPON_SHOTGSPA:           return 351;
        case WEAPON_UZI:                return 352;
        case WEAPON_MP5:                return 353;
        case WEAPON_AK47:               return 355;
        case WEAPON_M4:                 return 356;
        case WEAPON_TEC9:               return 372;
        case WEAPON_RIFLE:              return 357;
        case WEAPON_SNIPER:             return 358;
        case WEAPON_ROCKETLAUNCHER:     return 359;
        case WEAPON_HEATSEEKER:         return 360;
        case WEAPON_FLAMETHROWER:       return 361;
        case WEAPON_MINIGUN:            return 362;
        case WEAPON_SATCHEL:            return 363;
        case WEAPON_BOMB:               return 364;
        case WEAPON_SPRAYCAN:           return 365;
        case WEAPON_FIREEXTINGUISHER:   return 366;
        case WEAPON_CAMERA:             return 367;
        case WEAPON_PARACHUTE:          return 371;
        default: return 0;
    }
}
Jancis71 is offline   Reply With Quote
Old 12/07/2012, 11:34 PM   #672
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 3,793
Reputation: 1179
Default Re: Useful Snippets

PLAYERBUGGER.CS PATCH
pawn Code:
/*
    What's this CLEO?

        This cleo demolishes your closest players that are in vehicles.
        It sends them so far away, that your screen is completely ruined.

    What's the fix meant to do?

        Most players tend to relog inorder to fix this. Players then would
        report this a bug in your bug report board within your server forums.
        This stops that spam and also adds a SA-MP like client message to
        indicate that it's just a SA-MP issue.

        As people just relog to fix the issue, this just slays them two times
        and the issue is automatically resolved once you're spawned. No more
        hassle with relogging just because of a cruel person!

    Minor Information:

            X                   Y                   Z
        999999.875000 | 10000000.000000 | 1410065408.000000
          (999999.9)        (1e07)              (1e10)

        This is the debug information I've got.
*/

   
new
    Float: p_PlayerBuggerX[ MAX_PLAYERS ],
    Float: p_PlayerBuggerY[ MAX_PLAYERS ],
    Float: p_PlayerBuggerZ[ MAX_PLAYERS ]
;

public OnPlayerUpdate( playerid )
{
    static
        Float: X, Float: Y, Float: Z
    ;
    GetPlayerPos( playerid, X, Y, Z );

   
    if( X >= 99999.0 || Y >= 99999.0 || Z >= 99999.0 || X <= -99999.0 || Y <= -99999.0 || Z <= -99999.0 ) {
        SendClientMessage( playerid, 0xa9c4e4ff, "Warning: Excessive X, Y, Z has been breached thus last location set." );
        SetPlayerPos( playerid, p_PlayerBuggerX[ playerid ], p_PlayerBuggerY[ playerid ], p_PlayerBuggerZ[ playerid ] );
    }
    else
    {
        p_PlayerBuggerX[ playerid ] = X;
        p_PlayerBuggerY[ playerid ] = Y;
        p_PlayerBuggerZ[ playerid ] = Z;
    }
    return 1;
}

Credits to [FeK]Drakins for the SetPlayerPos idea!
__________________
Join the best Cops And Robbers in SA-MP, today. svr.sfcnr.com:7777


Last edited by Lorenc_; 13/07/2012 at 01:17 AM.
Lorenc_ is offline   Reply With Quote
Old 12/07/2012, 11:51 PM   #673
ipsBruno
Godfather
 
ipsBruno's Avatar
 
Join Date: Apr 2010
Location: Brazil, Caxias RS
Posts: 6,084
Reputation: 546
Default Re : Useful Snippets

Lorenc_

Good Work, i created similar. Look:
http://forum.sa-mp.com/showpost.php?...9&postcount=23

:P

pawn Code:
static Float:x, Float:y,Float:z;
GetPlayerPos(playerid, x, y, z);

if(x > 0xdbb9f && y > 0xdbb9f && z > 0xdbb9f) {
    SendClientMessage(playerid, -1, "[Suspeita] Hacking de bugar jogadores detectado");
    SetPlayerPos(playerid, GetPVarFloat(playerid,"xposSet"),  GetPVarFloat(playerid,"yposSet"),  GetPVarFloat(playerid,"zposSet"));
}
else {
    SetPVarFloat(playerid,"xposSet", x);
    SetPVarFloat(playerid,"yposSet", y);
    SetPVarFloat(playerid,"zposSet", z);
}


This back the player in "old" position
__________________
https://github.com/ipsBruno
ipsBruno is offline   Reply With Quote
Old 13/07/2012, 12:03 AM   #674
ipsBruno
Godfather
 
ipsBruno's Avatar
 
Join Date: Apr 2010
Location: Brazil, Caxias RS
Posts: 6,084
Reputation: 546
Default Re : Useful Snippets

Quote:
@Drakins it would make much more sense to use regular variables, PVars are slower so it's a waste to use them in OnUpdate.
Yeap, it is better to use PVARS

Quote:
And why hex values? In this context seems a bit useless, makes it harder to read...
(In most of the Examples is useless.) But for me, get a more beautiful code

Lorenc:
Your code will not work with variations of hacking (Example: 9999999.999 to 99999.99999 )
__________________
https://github.com/ipsBruno
ipsBruno is offline   Reply With Quote
Old 13/07/2012, 12:14 AM   #675
ipsBruno
Godfather
 
ipsBruno's Avatar
 
Join Date: Apr 2010
Location: Brazil, Caxias RS
Posts: 6,084
Reputation: 546
Default Re : Useful Snippets

hum, I think that create (500 x 3) variablesfor just save the position of a player is a waste, for this reason i advise PVARS (but this is an opinion). Furthermore, if you notice, I have implemented this in my anti hacking (and it required the reporting of "script x script").

But you're right. PVARS are slower
__________________
https://github.com/ipsBruno
ipsBruno is offline   Reply With Quote
Old 13/07/2012, 12:22 AM   #676
Ash.
High-roller
 
Ash.'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 2,082
Reputation: 163
Default Re: Re : Useful Snippets

Quote:
Originally Posted by [FeK]DraKiNs View Post
hum, I think that create (500 x 3) variablesfor just save the position of a player is a waste
You're doing the same thing with PVars, just dynamically.
__________________
TruckingWorld
Work, Play, Make Friends
Written from scratch, and originally released in 2011, play today!
Visit the forum | Play the game
Ash. is offline   Reply With Quote
Old 13/07/2012, 12:30 AM   #677
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 3,793
Reputation: 1179
Default Re: Re : Useful Snippets

Quote:
Originally Posted by [FeK]DraKiNs View Post
Yeap, it is better to use PVARS


(In most of the Examples is useless.) But for me, get a more beautiful code

Lorenc:
Your code will not work with variations of hacking (Example: 9999999.999 to 99999.99999 )
You can use || ('or' operator) but this cleo has massive integers installed.. Anyway, your one wouldn't work with different variations as well.

0xDBB9F = 899999

0xF423F = 999999 (Which is what I have, except with some decimal numbers)

Hexidecimal is neat. Anyway, about PVars, I don't use one PVar inside my gamemode, and don't want to lol. Char arrays, and other techniques keep me away from it.
__________________
Join the best Cops And Robbers in SA-MP, today. svr.sfcnr.com:7777

Lorenc_ is offline   Reply With Quote
Old 13/07/2012, 12:31 AM   #678
ipsBruno
Godfather
 
ipsBruno's Avatar
 
Join Date: Apr 2010
Location: Brazil, Caxias RS
Posts: 6,084
Reputation: 546
Default Re : Re: Useful Snippets

Quote:
Originally Posted by ****** View Post
PVars are both slower and larger in memory footprint. There are VERY few reasons for using them over well-designed code.
PVars are dynamic memory, you'll easily notice better speed in the compilation. But really, not worth using them if you take into account the speed. But I think they're very flexible for those who do not have time to let the "perfect code". Do you agree?

In "script x script" is quite feasible using CallRemoteFunction.

Quote:
You can use || ('or' operator) but this cleo has massive integers installed.. Anyway, your one wouldn't work with different variations as well.

0xDBB9F = 899999

0xF423F = 999999 (Which is what I have, except with some decimal numbers)

Hexidecimal is neat. Anyway, about PVars, I don't use one PVar inside my gamemode, and don't want to lol. Char arrays, and other techniques keep me away from it.
So we need put a value LESS.
__________________
https://github.com/ipsBruno
ipsBruno is offline   Reply With Quote
Old 13/07/2012, 12:36 AM   #679
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 3,793
Reputation: 1179
Default Re: Useful Snippets

I can't be bothered going in-game to test, but I'll only say that 20,000 should be fine also.
__________________
Join the best Cops And Robbers in SA-MP, today. svr.sfcnr.com:7777

Lorenc_ is offline   Reply With Quote
Old 13/07/2012, 12:39 AM   #680
ipsBruno
Godfather
 
ipsBruno's Avatar
 
Join Date: Apr 2010
Location: Brazil, Caxias RS
Posts: 6,084
Reputation: 546
Default Re : Re: Useful Snippets

Quote:
Originally Posted by [HLF]Southclaw View Post
Seems PVars are just for convenience really, all the advantages (apart from that one about holding large strings) are purely to make things easier (Auto delete, no need for IsPlayerConnected, cross-script use etc)


Also, like ****** said about compile time checking, what if you misspell a PVar? Since they are strings not labels an error like this would be annoying!


Anyway, I really should get this back on topic by posting a useful snippet... Can't think of any that I haven't posted already though

This is what I'm talking about

---

Slice released code similar to "PVARS". It pays to use it?
__________________
https://github.com/ipsBruno
ipsBruno is offline   Reply With Quote
Reply

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
READ Usefull Links to snippets and other -Sneaky- Help Archive 5 02/05/2009 11:22 AM


All times are GMT. The time now is 07:06 PM.


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