[Include] svAddons - Useful Scripting Addons
#1

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 (****** 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 Код:
#include <svAddons>
at the top of your script.


Credits

SuperViper - Creating the script
Reply


Messages In This Thread
svAddons - Useful Scripting Addons - by SuperViper - 03.06.2012, 23:14
Re: svAddons - Useful Scripting Addons - by Shadow_ - 03.06.2012, 23:18
Respuesta: svAddons - Useful Scripting Addons - by Dx2 - 03.06.2012, 23:23
Re: svAddons - Useful Scripting Addons - by Cacoby - 03.06.2012, 23:59
Re: svAddons - Useful Scripting Addons - by Basssiiie - 04.06.2012, 00:28
Re: svAddons - Useful Scripting Addons - by ikey07 - 04.06.2012, 01:01
Re: svAddons - Useful Scripting Addons - by SuperViper - 04.06.2012, 01:27
Re: svAddons - Useful Scripting Addons - by MP2 - 04.06.2012, 01:29
AW: svAddons - Useful Scripting Addons - by Invizion - 04.06.2012, 10:41
Re: svAddons - Useful Scripting Addons - by Firo - 04.06.2012, 11:13
Re: svAddons - Useful Scripting Addons - by TheArcher - 04.06.2012, 11:40
Re: svAddons - Useful Scripting Addons - by Jochemd - 04.06.2012, 12:44
Re: svAddons - Useful Scripting Addons - by Littlehelper - 04.06.2012, 15:38
Re: svAddons - Useful Scripting Addons - by TheArcher - 04.06.2012, 17:07
Re: svAddons - Useful Scripting Addons - by Roperr - 04.06.2012, 17:14
Re: svAddons - Useful Scripting Addons - by SuperViper - 04.06.2012, 17:20
Re: svAddons - Useful Scripting Addons - by FireCat - 04.06.2012, 17:27
Re: svAddons - Useful Scripting Addons - by StreetGT - 04.06.2012, 18:20
Re: svAddons - Useful Scripting Addons - by Jochemd - 04.06.2012, 19:53
Re: svAddons - Useful Scripting Addons - by SuperViper - 04.06.2012, 20:53
Re: svAddons - Useful Scripting Addons - by Y_Less - 04.06.2012, 21:48
Re: svAddons - Useful Scripting Addons - by MP2 - 04.06.2012, 21:55
Re: svAddons - Useful Scripting Addons - by Y_Less - 04.06.2012, 23:25
Re: svAddons - Useful Scripting Addons - by DonWade - 04.06.2012, 23:56
Re: svAddons - Useful Scripting Addons - by pasha97 - 05.06.2012, 05:06
Re: svAddons - Useful Scripting Addons - by SuperViper - 19.06.2012, 22:11
Re: svAddons - Useful Scripting Addons - by rickysmum - 20.06.2012, 16:52
Re: svAddons - Useful Scripting Addons - by SuperViper - 25.06.2012, 03:26
Re: svAddons - Useful Scripting Addons - by SuperViper - 14.07.2012, 20:31
Re: svAddons - Useful Scripting Addons - by Gleam - 02.09.2018, 22:44

Forum Jump:


Users browsing this thread: 1 Guest(s)