SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 11/03/2018, 05:48 PM   #1261
Lokii
Big Clucker
 
Join Date: Sep 2017
Posts: 117
Reputation: 59
Default Re: Useful Snippets

GetVehicleSpeed:

PHP Code:
GetVehicleSpeed(vehicleidtype)
{
    new 
s;
    new 
Float:xFloat:yFloat:z;
    
GetVehicleVelocity(vehicleidxyz);
    switch(
type)
    {
        case 
1floatround((floatsqroot(floatpower(x2) + floatpower(y2) + floatpower(z2)))*112.1577floatround_round);
        default: 
floatround((floatsqroot(floatpower(x2) + floatpower(y2) + floatpower(z2)))*180.5000floatround_round);
    }
    return 
s;

Types:

Code:
type 1 - mph
any other type - kmh
Example:

PHP Code:
public sometcallaback(playerid)
{
    new 
str[3];
    
format(strsizeof(str), "%d"GetVehicleSpeed(GetPlayerVehicleID(playerid), 0));
    
GameTextForPlayer(playeridstr1004);
    return 
1;

Lokii is offline   Reply With Quote
Old 13/03/2018, 03:17 PM   #1262
RogerCosta
Huge Clucker
 
RogerCosta's Avatar
 
Join Date: Aug 2014
Location: Santos, Brazil.
Posts: 330
Reputation: 88
Default Re: Useful Snippets

Code:
stock RemovePlayerWeapon(playerid, weaponid) {
	if(GetPlayerWeapon(playerid) == weaponid) {
		GivePlayerWeapon(playerid, weaponid, -GetPlayerAmmo(playerid));
	}
	else {
		new slot, weapon, ammo, currentWeapon = GetPlayerWeapon(playerid);
		for(new i = 0; i < 12; i++) {
			GetPlayerWeaponData(playerid, i, weapon, ammo);
			if(weapon == weaponid && ammo > 0) {
				GivePlayerWeapon(playerid, weaponid, -ammo);
				SetPlayerArmedWeapon(playerid, currentWeapon);
				break;
			}
		}
	}
}
RogerCosta is offline   Reply With Quote
Old 13/03/2018, 03:51 PM   #1263
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,723
Reputation: 780
Default Re: Useful Snippets

^^That won't work for melee weapons.
__________________
Gammix is offline   Reply With Quote
Old 02/04/2018, 12:13 PM   #1264
iKarim
Gangsta
 
iKarim's Avatar
 
Join Date: Oct 2015
Posts: 586
Reputation: 132
Default Re: Useful Snippets

Quote:
Originally Posted by Lokii View Post
forwardex:
I dislike such usage of macros, forwarding is more cleaner.
__________________
Quote:
Originally Posted by Maximun View Post
Did he requested you some 'Kilobytes' in order to post this thread?
iKarim is offline   Reply With Quote
Old 19/04/2018, 03:43 PM   #1265
Lokii
Big Clucker
 
Join Date: Sep 2017
Posts: 117
Reputation: 59
Default Re: Useful Snippets

Check player skin gender

PHP Code:
static const female_skins[] =
{
    
910111213313940415354555663,
    
6465697576778587888990919293,
    
129130131138139140141145148150151151,
    
157169172178190191192193194195196197,
    
198199201205207211214215216218219224,
    
225226231232233237238243244245246251,
    
256257263298
};

IsFemale(playerid)
{
    for(new 
0sizeof(female_skins); x++)
    {
        if(
GetPlayerSkin(playerid) == female_skins[x]) return 1;
    }
    return 
0;
}

CMD:gender(playerid)
{
    if(
IsFemale(playerid)) return SendClientMessage(playerid0x00FF00FF"Female");
    if(!
IsFemale(playerid)) return SendClientMessage(playerid0xFFFF00FF"Male");
    return 
1;

Lokii is offline   Reply With Quote
Old 22/05/2018, 02:25 PM   #1266
Zorono
Huge Clucker
 
Zorono's Avatar
 
Join Date: Dec 2015
Location: Africa, Egypt, Alexandria
Posts: 362
Reputation: 30
Thumbs up Re: Useful Snippets

A little snippet which checks whether Vehicle's Seat is Taken or not by Vehicle ID&Seat ID(optional)
[hr]

Code:
IsVehicleSeatTaken(vehicleid, seatid = 0)
{
    for(new p = 0; p < GetMaxPlayers(); p++)
    {
        if(!IsPlayerConnected(p)) continue;
        if(GetPlayerVehicleID(p) == vehicleid)
        {
           switch(GetPlayerVehicleSeat(p))
           {
              case -1: return (seatid == GetPlayerVehicleSeat(p));
              case 0: return (seatid == GetPlayerVehicleSeat(p));
              case 1,2,3: return (seatid == GetPlayerVehicleSeat(p));
              default: return false; // to avoid being crashed because of the invalid seat id 128....
           }
        }
    }
    return 0; 
}
Zorono 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 09:51 AM.


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