SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 03/06/2012, 11:14 PM   #1
SuperViper
Gangsta
 
SuperViper's Avatar
 
Join Date: Sep 2011
Posts: 979
Reputation: 278
Default svAddons - Useful Scripting Addons

Introduction

This script adds some useful functions that the SA:MP team decided to not include in the default server package. This include requires your server to be running on 0.3e.


Functions

FunctionActionReturns
SetPlayerSpecialAction(playerid, actionid)If the special action is USECELLPHONE or STOPUSECELLPHONE, it will automatically attach/detach the phone1
IsPlayerInWater(playerid) or IsPlayerSwimming(playerid)Checks if a player is swimming1 if the player is swimming, otherwise 0
SetPlayerPosEx(playerid, Float: posX, Float: posY, Float: posZ, interior = 0, virtualworld = 0, Float: angle = 0.0)Sets a player's position, virtual world, interior, and angle1
GetPlayersName(playerid)Gets the player's nameThe player's name
GetPlayersNameEx(playerid)Gets the player's name and removes the underscoresThe player's name without underscores
CrashPlayer(playerid)Crashes the player1
GetPlayersIP(playerid)Gets the player's IPThe player's IP
ExplodePlayer(playerid)Explodes a player1
ExplodeVehicle(vehicleid)Explodes a vehicle1
SetPlayerMoney(playerid, amount)Sets the players money1
GivePlayerJetpack(playerid)Gives the player a jetpack1
IsPlayerSpawned(playerid)Checks if the player is spawned1 if the player is spawned, otherwise 0
GetVehicleInfo(vehicleid, infoType)Gets the status of one of the vehicle parameters (for infoType you can use VEHICLE_INFO_PARAMNAME)The status of the vehicle parameter
SetVehicleInfo(vehicleid, infoType, value)Sets the status of one of the vehicle paramters (for infoType you can use VEHICLE_INFO_PARAMNAME)1
IsPlayerInVehicleFireMode(playerid)Checks if the player is drivebying as a passenger1 if the player is drivebying as a passenger, otherwise 0
GetVehicleDriver(vehicleid)Gets the driver of the vehicleThe driver's ID
GetVehiclePassengers(vehicleid, &passengerOne = INVALID_PLAYER_ID, &passengerTwo = INVALID_PLAYER_ID, &passengerThree = INVALID_PLAYER_ID)Gets the vehicle's passengers (will not retrieve more than the first 3 passengers for bus/coach)The vehicle's passengers for each seat
GetVehicleNumberPlate(vehicleid)Gets the vehicle's license plateThe vehicle's license plate
IsPlayerSpectating(playerid)Checks if the player is spectating1 if the player is spectating, otherwise 0
GetPlayerObjectEditingState(playerid)Gets the player's object editing state (OBJECT_EDITING_STATE_NONE, NORMAL, PLAYER, ATTACHED)The player's object editing state
GetPlayerEditingObject(playerid)Gets the object the player is editing (attached object index if editing attached object)The object the player is editing
RemovePlayerWeapon(playerid, weaponid)Removes a weapon from a player1
ClosePlayerDialog(playerid)Closes a player's dialog1
SetPlayerDeathEffect(playerid, deffid)Sets the player's death effect (DEATH_EFFECT_NONE, REDGAS, SMOKE, EXPLODE, MINIEXPLODE, FIRE)1
GetPlayerDeathEffect(playerid)Gets the player's death effectThe player's death effect
DisableSprunkMachines()Used in OnGameModeInit to remove all sprunk machines from the map1
ChangeServerPassword(password[])Changes the server password1
LoadFilterscript(scriptName[], bool: reload = false)Loads a filterscript1
UnloadFilterscript(scriptName[])Unloads a filterscript1
ChangeServerName(serverName[])Changes the server name1
SendServerRCONMessage(message[])Sends a message to the server via RCON 'say' command1
SendMessageToRCONAdmins(color, message[])Sends a message to all in-game RCON admins1
ChangeServerWebsite(url[])Changes the server's website URL1
ChangeMapName(mName[])Changes the server's map name1
IsValidSkin(skinID)Checks if the skin is valid1 is the skin is valid, otherwise 0
ClearPlayersChat(playerid, bool: includeScrollingChat = false)Clears the player's currently displayed chat or all chat1
ClearAllPlayersChat(bool: includeScrollingChat = false)Clears all of the player's currently displayed chat or all chat1
TeleportPlayerToPlayer(playerid, giveplayerid, Float: offsetX = 1.0, Float: offsetY = 0.0, Float: offsetZ = 0.0)Teleports a player to another player1
StopVehicleMovement(vehicleid)Smoothly stops a vehicle's movement1
GetVehicleSpeed(vehicleid)Gets the vehicle's speedThe vehicle's speed
GetVehicleModelName(modelID)Gets the name of the vehicle model IDThe vehicle model ID's name
GetVehicleIDFromName(string[], bool: useFind = false)Gets a vehicle's model ID from a nameThe vehicle's model ID
GetWeaponID(weaponName[], bool: ignoreCase = true, bool: useFind = false)Gets a weapon's ID from a weapon's nameThe weapon's ID
GetPlayerIDFromIP(ip[], bool: useFind = false)Gets the player ID that has specified IPThe player's ID
CountTotalPlayers()Gets the amount of connected playersThe amount of connected players
CountTotalRCONAdmins()Gets the amount of connected RCON adminsThe amount of connected RCON admins
CountTotalNPCs()Gets the amount of connected NPCsThe amount of connected NPCs
CountTotalPausedPlayers()Gets the amount of connected paused playersThe amount of connected paused players
GetVehiclesAngle(vehicleid)Gets the vehicle's angleThe vehicle's angle
GetVehiclesHealth(vehicleid)Gets the vehicle's healthThe vehicle's health
GetPlayersHealth(playerid)Gets the player's healthThe player's health
GetPlayersArmour(playerid)Gets the player's armorThe player's armor
EnableWhitelist(mode = WHITELIST_MODE_ALLOWPLAYER, ip[] = "")Enables RCON whitelisting with several modes (WHITELIST_MODE_NONE, ALLOWPLAYER, SPECIFICIP, IP_FIND)1
GetWhitelistMode()Gets the server's RCON whitelist modeThe server's RCON whitelist mode
AddPlayerToWhitelist(playerid)Adds a player to the RCON whitelist1
IsPlayerWhitelisted(playerid)Checks if a player is on the RCON whitelist1 if the player is on the RCON whitelist, otherwise 0
GetVehicleInterior(vehicleid)Gets a vehicle's interiorThe vehicle's interior
IsPlayerBehindVehicle(playerid, vehicleid)Checks if a player is behind a vehicle1 if the player is behind the vehicle, otherwise 0
ShakePlayerScreen(playerid, duration = 1250)Shakes a player's screen1
ReconnectPlayer(playerid)Reconnects a player to the server without closing their game1
GetVehicleTrailerCount(vehicleid)Gets the amount of trailers attached to the vehicleThe amount of trailers attached to the vehicle
GetFreeVehicleSeat(vehicleid)Gets the next free seat in a vehicleIf a seat is available, the seat id, otherwise INVALID_VEHICLE_ID
GetVehicleSpawnInfo(vehicleid, &Float: spawnX, &Float: spawnY, &Float: spawnZ, &Float: spawnR, &color1, &color2, &respawndelay)Gets the information the vehicle was spawned withThe information the vehicle was spawned with
CapitalizePlayerName(playerid)Capitalizes a player's name (including letters after underscores)1
GetPlayerTemporaryName(playerid)Gets a temporary name for the player if you need to use their name for somethingThe player's temporary name
GetStringCharacterCount(string[], character)Gets the amount of the specified character in a stringThe amount of the specified character in the string
SetVehiclePosEx(vehicleid, Float: posX, Float: posY, Float: posZ, interior = 0, virtualworld = 0, Float: angle = 0.0)Sets a vehicle's position, rotation, interior, and virtual world1
SendNearbyClientMessage(color, message[], Float: distance = 30.0, Float: posX, Float: posY, Float: posZ, interior = 0, virtualworld = 0)Sends a client message to players near the specified point1
GameTextForNearbyPlayers(text[], time, style, Float: distance = 30.0, Float: posX, Float: posY, Float: posZ, interior = 0, virtualworld = 0)Displays game text on the screen of players that are near the specified point1
ToggleNearbyPlayersControllable(bool: controllable, Float: distance = 30.0, Float: posX, Float: posY, Float: posZ, interior = 0, virtualworld = 0)Toggles weather players near the point can move and turn their camera1
TogglePlayerKickImmunity(playerid, bool: immune)Decides weather the player can be kicked or not1
GetPlayerKickImmunity(playerid)Gets the player's kick immunity statusThe player's kick immunity status
TogglePlayerBanImmunity(playerid, bool: immune)Decides weather the player can be banned or not1
GetPlayerBanImmunity(playerid)Gets the player's ban immunity statusThe player's ban immunity status
CreateTriggerPoint(Float: posX, Float: posY, Float: posZ, interior = 0, virtualworld = 0)Creates an invisible trigger point at the specified location which calls OnPlayerTouchTrigger when a player touches itThe trigger's ID
StartCountdown(from = 3)Starts a countdown for all playersThe timer's ID
SendClientAudioMessage(playerid, message[], bool: withClientMessage = false, color = -1, language[] = "en")Sends a message to the player in an audio stream (Google Translator)1
DealPlayerDamage(playerid, damage)Deals a certain amount of damage to a player (checks weather to take health, armor, or both)1
TeleportPlayers(Float: posX, Float: posY, Float: posZ, interior, virtualworld, Float: angle, ...)Teleports an unlimited amount of players to a location - Untested1
CountTotalVehicles()Gets the amount of vehicles createdThe amount of vehicles created
IsVehicleOccupied(vehicleid)Checks if the vehicle is occupied0 if no, otherwise 1
IsPlayerDrivingVehicle(playerid, vehicleid = INVALID_VEHICLE_ID)Checks if a player is driving a vehicle0 if no, otherwise 1
TeleportPlayerToVehicle(playerid, vehicleid, Float: offsetX = 1.0, Float: offsetY = 0.0, Float: offsetZ = 0.0)Teleports a player to a vehicle1
GetPickupPos(pickupid, &Float: X, &Float: Y, &Float: Z)Gets a pickup's position1
GetPickupVirtualWorld(pickupid)Gets a pickup's virtual world1
HideAllTextDraws()Hides all text draws for all players1
HideAllTextDrawsForPlayer(playerid)Hides all text draws for the specified player1
GetSkinGender(skinid)Get's the specified skin's genderThe skin's gender (SKIN_GENDER_NONE, SKIN_GENDER_MALE, SKIN_GENDER_FEMALE)
TogglePlayerWeaponSwitch(playerid, bool: togws)Toggles weather the player can switch weapons or not1
IsMeleeWeapon(weaponid)Checks if the specified weapon is a melee weapon1 if the weapon is a melee weapon, otherwise 0
IsPlayerPaused(playerid) or IsPlayerTabbed(playerid)Checks if a player is paused1 if the player is paused, otherwise 0
GetPlayerControllable(playerid)Checks if a player can control himself1 if the player can control himself, otherwise 0
divideRem(a, b, &answer, &remainder)Divides two numbers and retrieves the answer with the remainder1
CountTotalObjects()Counts the total objects currently created on the serverThe total objects currently created on the server
GetServerStats(&connections, &kicks, &vehicles, &objects, &players, &totalvehicles, &totalobjects, &kills, &deaths, &totaldamage, mode = SERVER_STATS_UPTIME, bool: errorContinue = true)Retrieves the server's stats1


Callbacks

CallbackCall Time
OnVehicleCreate(vehicleid)Called when a vehicle is created (not respawned)
OnPlayerPausedUpdate(playerid, bool: paused)Called when a player pauses or unpauses
OnPlayerWeaponUpdate(playerid, newgun, oldgun)Called when a player changes their weapon
OnReceiveClientMessage(playerid, color, message[])Called when a player receives a client message (includes audio stream message and does not include SendClientMessageToAll)
OnRconLoginBlocked(playerid, ip[], password[], success)Called when a player is blocked by the RCON whitelist feature
OnPlayerWaterStatusUpdate(playerid, bool: inWater)Called when a player enters or exits water
OnPlayerSpecialActionChange(playerid, oldaction, newaction)Called when a player's special action changes (not yet working for sprunk and cigars)
OnPlayerTouchTrigger(playerid, triggerid)Called when a player touches a trigger created with CreateTriggerPoint


Maximum Definitions

DefinitionValue
MAX_INTEGER_LENGTH12
MAX_IP_LENGTH17
MAX_WEAPON_NAME24
MAX_CLIENT_MESSAGE128
MAX_WEAPON_AMMO32767
MAX_INTEGER_VALUE2147483647


Preset Variable Sizes

You can now define variables using a couple of new macros I have created. They have preset sizes specifically for the function they'll be used for.

DeclarationSize
S_IP[variable name]17
S_Player[variable name]MAX_PLAYER_NAME or 24
S_Weapon[variable name]MAX_WEAPON_NAME (custom definition) or 24
S_Chat[variable name]MAX_CLIENT_MESSAGE (custom definition) or 128


Bugs and Suggestions

Please reply to this thread with your bug report or suggestion for the include. All of these posts will be reviewed carefully and dealt with.


Versions

The download links and the include itself will be updated occasionally.

Version 1.4 - Pastebin | Mediafire | Assembla Direct Download
Version 1.3 - Pastebin | Mediafire | Assembla Direct Download
Version 1.2 - Pastebin | Mediafire | Assembla Direct Download
Version 1.1 - Pastebin | Mediafire | Assembla Direct Download
Version 1.0 - Pastebin | Mediafire | Assembla Direct Download



Don't want to wait for updates?

I'm currently uploading all of my changes to an Assembla account. Assembla will be updated before updates are released. If you wish to get the files directly from Assembla, use SVN Checkout with this URL: https://subversion.assembla.com/svn/sv-libraries/

My latest updates to Assembla are below:




Changelog

VersionChange
Version 1.4Added preset variable sizes (more information available above)
Version 1.4Added maximum value defines for several things (more information available above)
Version 1.4Added the structure for the soon to come DisableLagShooting function
Version 1.4Added GetServerStats function
Version 1.4Added CountTotalObjects function
Version 1.4Added divideRem function
Version 1.4Added GetPlayerControllable function
Version 1.4Added IsMeleeWeapon function
Version 1.4Added IsPlayerPaused or IsPlayerTabbed function
Version 1.4Added TogglePlayerWeaponSwitch function
Version 1.4Added GetSkinGender function
Version 1.4Added HideAllTextDrawsForPlayer function
Version 1.4Added HideAllTextDraws function
Version 1.3Added GetPickupVirtualWorld function
Version 1.3Added GetPickupPos function
Version 1.3Added TeleportPlayerToVehicle function
Version 1.3Added IsPlayerDrivingVehicle function
Version 1.3Added IsVehicleOccupied function
Version 1.3Added CountTotalVehicles function
Version 1.3Added TeleportPlayers function
Version 1.2Added DealPlayerDamage function
Version 1.2Added SendClientAudioMessage function
Version 1.2Added StartCountdown function
Version 1.2Added CreateTriggerPoint function
Version 1.2Added TogglePlayerBanImmunity and GetPlayerBanImmunity functions
Version 1.2Added TogglePlayerKickImmunity and GetPlayerKickImmunity functions
Version 1.2Added ToggleNearbyPlayersControllable function
Version 1.2Added GameTextForNearbyPlayers function
Version 1.2Added SendNearbyClientMessage function
Version 1.2Added SetVehiclePosEx function
Version 1.2Added GetStringCharacterCount function
Version 1.2Added GetPlayerTemporaryName function
Version 1.2Added CapitalizePlayerName function
Version 1.2Added GetVehicleSpawnInfo function
Version 1.2Added GetFreeVehicleSeat function
Version 1.2Added OnPlayerSpecialActionChange and OnPlayerTouchTrigger callbacks
Version 1.1Added OnPlayerWaterStatusUpdate callback
Version 1.1Added ReconnectPlayer and GetVehicleTrailerCount functions
Version 1.1Removed IsPlayerInSpray function due to issues with camera mode detection
Version 1.0Created the script


Using

To begin using this include, drag the file to your pawno > includes folder and put

pawn Code:
#include <svAddons>

at the top of your script.


Credits

SuperViper - Creating the script
__________________
Release NameUse
Object Model ArrayArray of every single object model in the game
RCON PanelControl any server as you like with RCON controls
svAddonsAdds several functions and callbacks to further expand your scripting experience and make it easier
SlopeClimb up a steep hill against other players with cars falling down

“Everybody is a genius but if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.”



Last edited by SuperViper; 07/10/2012 at 02:41 PM.
SuperViper is offline   Reply With Quote
Old 03/06/2012, 11:18 PM   #2
Shadow_
Gangsta
 
Shadow_'s Avatar
 
Join Date: Nov 2008
Location: Vatican City
Posts: 528
Reputation: 37
Default Re: svAddons - Useful Scripting Addons

Well done, some really useful functions. Granted some have been posted before, but great all the same.
__________________
Shadow_ is offline   Reply With Quote
Old 03/06/2012, 11:23 PM   #3
Dx2
Little Clucker
 
Dx2's Avatar
 
Join Date: May 2012
Location: Uruguay
Posts: 44
Reputation: 0
Default Respuesta: svAddons - Useful Scripting Addons

omg nice functions, thanks a lot
Dx2 is offline   Reply With Quote
Old 03/06/2012, 11:59 PM   #4
Cacoby
Huge Clucker
 
Cacoby's Avatar
 
Join Date: Jul 2010
Posts: 223
Reputation: 0
Default Re: svAddons - Useful Scripting Addons

O: very userfull, tnx dude
Cacoby is offline   Reply With Quote
Old 04/06/2012, 12:28 AM   #5
Basssiiie
Gangsta
 
Basssiiie's Avatar
 
Join Date: Mar 2011
Location: The Netherlands
Posts: 726
Reputation: 138
Default Re: svAddons - Useful Scripting Addons

Code:
stock IsPlayerInSpray(playerid)
{
        return (GetPlayerCameraMode(playerid) == 15) ? 1 : 0;
}
Someone did not do his homework. This is very unreliable and the Wiki is quite wrong here. I regret that I can't change it, I don't have a Wiki account. (I have asked, no response.)

Yes, camera mode 15 is Pay & Spray. But Pay & Spray is not the only camera mode 15. I prefer calling camera mode 15 'scripted static camera'. It's used for a lot of different stuff, like:
  • Entering and exiting interiors through the normal enex, the small cutscene of the player walking through the door is camera mode 15.
  • The mod shops are camera mode 15.
  • Some of the chasing sequences are camera mode 15.
  • Buying food at fast food restaurants (Pizza shop, Burger Shot, Cluckin' Bell...) sets you in camera mode 15.
  • SetPlayerCameraPos is camera mode 15.
They have all one thing in common: the location where the camera itself is located, isn't moving at all. (Like following a player, or attached to a vehicle) It's as static as it can be. The direction the camera is looking does change in some cases, for example with the chasing cameras.
Basssiiie is offline   Reply With Quote
Old 04/06/2012, 01:01 AM   #6
ikey07
Gangsta
 
ikey07's Avatar
 
Join Date: Jul 2010
Location: Latvia,Riga
Posts: 728
Reputation: 74
Default Re: svAddons - Useful Scripting Addons

Really useful, thanks
__________________


ikey07 is offline   Reply With Quote
Old 04/06/2012, 01:27 AM   #7
SuperViper
Gangsta
 
SuperViper's Avatar
 
Join Date: Sep 2011
Posts: 979
Reputation: 278
Default Re: svAddons - Useful Scripting Addons

Quote:
Originally Posted by Basssiiie View Post
Code:
stock IsPlayerInSpray(playerid)
{
        return (GetPlayerCameraMode(playerid) == 15) ? 1 : 0;
}
Someone did not do his homework. This is very unreliable and the Wiki is quite wrong here. I regret that I can't change it, I don't have a Wiki account. (I have asked, no response.)

Yes, camera mode 15 is Pay & Spray. But Pay & Spray is not the only camera mode 15. I prefer calling camera mode 15 'scripted static camera'. It's used for a lot of different stuff, like:
  • Entering and exiting interiors through the normal enex, the small cutscene of the player walking through the door is camera mode 15.
  • The mod shops are camera mode 15.
  • Some of the chasing sequences are camera mode 15.
  • Buying food at fast food restaurants (Pizza shop, Burger Shot, Cluckin' Bell...) sets you in camera mode 15.
  • SetPlayerCameraPos is camera mode 15.
They have all one thing in common: the location where the camera itself is located, isn't moving at all. (Like following a player, or attached to a vehicle) It's as static as it can be. The direction the camera is looking does change in some cases, for example with the chasing cameras.
I don't focus on any function specifically making sure that it works just like wiki stated. I assume the wiki is correct because it's an official SA:MP wiki listed with every function. If it doesn't work, simply don't use it.
__________________
Release NameUse
Object Model ArrayArray of every single object model in the game
RCON PanelControl any server as you like with RCON controls
svAddonsAdds several functions and callbacks to further expand your scripting experience and make it easier
SlopeClimb up a steep hill against other players with cars falling down

“Everybody is a genius but if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.”


SuperViper is offline   Reply With Quote
Old 04/06/2012, 01:29 AM   #8
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 5,265
Reputation: 748
Default Re: svAddons - Useful Scripting Addons

The SA:MP wiki is edited by anyone (that has an account) - so it's not OFFICIAL OFFICIAL.
__________________
>> Click here for ALL of my releases
mGates - Create AUTOMATIC gates with ONE FUNCTION (+ restrictions i.e. team members only)
IEE (Interior Enter/Exits) - Create enex markers with one function
Cuffs - Cuff offsets for ALL SKINS!
vfunc - Vehicle functions. GetVehicleColor and synced random colors.
gBug - Prevent the 'G' bug (players being able to enter moving vehicles by pressing G then running after them).
MP2 is offline   Reply With Quote
Old 04/06/2012, 10:38 AM   #9
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629
Posts: 13,319
Reputation: 1910
Default Re: svAddons - Useful Scripting Addons

Very good effort. Just one tiny minor point. The callback hooks should use "CallLocalFunction" not "CallRemoteFunction" or you could end up having callbacks being called multiple times if this include is used in multiple scripts.
__________________
Y_Less is offline   Reply With Quote
Old 04/06/2012, 10:41 AM   #10
Invizion
Little Clucker
 
Join Date: Apr 2012
Posts: 17
Reputation: 0
Default AW: svAddons - Useful Scripting Addons

Nice man
__________________


Invizion 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
[FilterScript] Nice Addons For Gym kuberaland Filterscripts 4 25/04/2011 03:26 PM
[FS/MAP]Area 51 Addons (Decide to release now) HlHl Filterscripts 2 14/03/2010 05:25 AM
[FS/MAP]Area 51 Addons HlHl Filterscripts 3 02/03/2010 10:38 AM
[Map] [MAP] Unity Station Addons RastamaN[BzD] Maps 11 11/12/2009 04:51 AM
Useful FireFox addons :D [List on first post :P ] Rozzie Everything and Nothing 19 18/01/2009 10:16 PM


All times are GMT. The time now is 08:38 AM.


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