Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

[Tutorial] Functions/Callbacks & Useful links.

$
0
0
Neglected Functions/Callbacks

Well i went scrolling through SA-MP Wiki to avoid seeing posts with functions/callbacks i never knew existed, not sure if this would count as a tutorial but it can contain things you didn't know existed before, i'll start with the callback its only one (not many callbacks after all)

OnIncomingConnection:
provided with the wiki link above this function is called before the OnPlayerConnect callback is called, i actually recently found out about this like a few weeks ago, this can be used to have more control and block players before they connect BUT please keep in mind that the information you try to extract under this callback is very limted, trying to use GetPlayerName will return into a blank text, if you want to see an example of use see my Anti reconnect flood snippet in my signature.
//==============//
Now the functions i found that i wasn't familiar with, note that the following i ignored all functions related to mysql as i won't post anything relevant to it cuz i'm not experienced about it whatsoever.
--
DetachTrailerFromVehicle:
Self explanatory, link attached to the above text, simply detach a trailer from a vehicle if there's any.
--
StopObject:
I had no idea this existed, i always thought i'd have to wait for the object to stop moving and didn't know we were able to stop it whilst it's movement so i usually interrupted it's movement by launching another movement.
--
AddPlayerClassEx:
Yeah i also didn't know that you were able to add players classes linked to a team.
--
Clamp:
I also recently found out about this, quoting wiki
Quote:

Force a value to be inside a range.
not sure but this can be useful and i never knew it was there.
--
funcidx:
Basic to comprehend, returns the id of the public function by its name although i'm not sure what area those ids in particular used for yet i never knew it was there.
--
GetPlayerSurfingObjectID:
Also found out about this and i can already think of using this in ways to create some minigames, the name exposes it all, returns the id of the object a player is surfing.
--
GetPlayerLastShotVectors:
I found out about this when i was trying to create an anti godmode cuz the godmode cheats did not trigger OnPlayerGive/TakeDamage so i tried to make it detect through the last shot vector by some player and then detect the closest player and compare his coords with the range of the last shot vector in 1.0 range, it worked great until i realized my timers accuracy could not stand strong in the face of ping delay and ended up shutting down the project.
--

GetPlayerWeaponState:
Basically checks the state of a weapon, also recently figured out this exists here's a Link of the states.
--
getarg:
This is interesting, the wiki example explains it best, i also didn't know about this ''The fourth argument (index 3)'' so yeah the more you know.
--
gpci:
Derived from the hash of the player's installation of samp, not unique (many players can have the same gpci serial) but can be helpful in terms of temporary banning a player (best to only last for hours then unban the serial) if he thinks he's cool cuz he can ban evade with a vpn.
--
heapspace:
I also stumbled across this while scrolling through the infinite list of functions on samp wiki, i think this can be used to predict the stack/heap warning you'd get on your pawno if you overuse maximized array variables?
--
ispacked:
i had no idea about this, and the fact that i found this and it made me get forwarded to this TUTORIAL is really useful and can help save memory i will for sure use this in the near future.
--

SHA256_PassHash:
The only reason i'm mentioning this is because from what I've read the best safe way to store passwords is salt-hash and this provides both in one step which is pretty awesome and i really needed this like a week ago... BUT you still have to generate a random salt for each password and for that i recommend this code by ryder
PHP Code:

// credits go to: RyDeR`
stock randomString(strDest[], strLen 10)
{
    while(
strLen--)
        
strDest[strLen] = random(2) ? (random(26) + (random(2) ? 'a' 'A')) : (random(10) + '0');


--
StartRecordingPlayerData:
I always wondered how npcs were recorded with the basic npc_record fs so i looked inside and i figured out about this, and i thought to myself how can i put this to use for my own... Then i got the idea of recording each player connecting movements and cutting it every hour and every time he changes state to break the files down and name them by state-date-time to avoid files overwriting each other, IT WORKED PERFECTLY! ... until i got the scriptfiles of 400 MGBS in one day and i ended up deleting the whole system and accepted the cruel fate.
--
valstr:
Its funny cuz i still remember that guy from the scripting help section asking how he can convert the integers into letters (string) and i didn't know about this then and then i suggested a loop through the text and a detection of numbers from 0 to 9 and replacement for them, if i could tag him here... so yeah this is useful.
================================================== ==========
That's about it, many other things i found but couldn't post here cuz i had no idea about i'll post the raw code of links and the functions meanings or callbacks right here:
Code:

http://wiki.sa-mp.com/wiki/DetachTrailerFromVehicle
DetachTrailerFromVehicle
=========
http://wiki.sa-mp.com/wiki/IsVehicleStreamedIn
IsVehicleStreamedIn
===========
http://wiki.sa-mp.com/wiki/StopObject
StopObject
==========
http://wiki.sa-mp.com/wiki/IsPlayerInCheckpoint
IsPlayerInCheckpoint
==========
http://wiki.sa-mp.com/wiki/AddPlayerClassEx
AddPlayerClassEx
==========
http://wiki.sa-mp.com/wiki/Atan
atan
=======
http://wiki.sa-mp.com/wiki/Clamp
Clamp
======
http://wiki.sa-mp.com/wiki/EnablePlayerCameraTarget
EnablePlayerCameraTarget
=========
http://wiki.sa-mp.com/wiki/EnableStuntBonusForPlayer
EnableStuntBonusForPlayer
=========
http://wiki.sa-mp.com/wiki/Existproperty
existproperty
=========
http://wiki.sa-mp.com/wiki/Fgetchar
fgetchar
=========
http://wiki.sa-mp.com/wiki/Fputchar
fputchar
=========
http://wiki.sa-mp.com/wiki/Funcidx
funcidx
========
http://wiki.sa-mp.com/wiki/GetNetworkStats
GetNetworkStats
========
http://wiki.sa-mp.com/wiki/GetObjectModel
GetObjectModel
=========
http://wiki.sa-mp.com/wiki/GetPlayerDistanceFromPoint
GetPlayerDistanceFromPoint
==========
http://wiki.sa-mp.com/wiki/GetVehicleDistanceFromPoint
GetVehicleDistanceFromPoint
=======
http://wiki.sa-mp.com/wiki/GetPlayerSurfingObjectID
GetPlayerSurfingObjectID
=========
http://wiki.sa-mp.com/wiki/GetPlayerLastShotVectors
GetPlayerLastShotVectors
========
http://wiki.sa-mp.com/wiki/GetPlayerKeys_FR
GetPlayerKeys_FR
========
http://wiki.sa-mp.com/wiki/GetPlayerWeaponState
GetPlayerWeaponState
=======
http://wiki.sa-mp.com/wiki/GetVehicleModelInfo
GetVehicleModelInfo
=======
http://wiki.sa-mp.com/wiki/Setarg
Setarg
=======
http://wiki.sa-mp.com/wiki/Getarg
Getarg
=======
http://wiki.sa-mp.com/wiki/Numargs
Numargs
=======
http://wiki.sa-mp.com/wiki/Gpci
Gpci
=======
http://wiki.sa-mp.com/wiki/Heapspace
Heapspace
=========
http://wiki.sa-mp.com/wiki/IsObjectMoving
IsObjectMoving
=====
http://wiki.sa-mp.com/wiki/IsPlayerStreamedIn
IsPlayerStreamedIn
=======
http://wiki.sa-mp.com/wiki/Ispacked
Ispacked
========
http://wiki.sa-mp.com/wiki/LimitGlobalChatRadius
LimitGlobalChatRadius
========
http://wiki.sa-mp.com/wiki/LimitPlayerMarkerRadius
LimitPlayerMarkerRadius
========
http://wiki.sa-mp.com/wiki/SetNameTagDrawDistance
SetNameTagDrawDistance
======
http://wiki.sa-mp.com/wiki/NetStats_BytesSent
NetStats_BytesSent
======
http://wiki.sa-mp.com/wiki/NetStats_BytesReceived
NetStats_BytesReceived
=======
http://wiki.sa-mp.com/wiki/SHA256_PassHash
SHA256_PassHash
========
http://wiki.sa-mp.com/wiki/SetPlayerArmedWeapon
SetPlayerArmedWeapon
======
http://wiki.sa-mp.com/wiki/SetPlayerChatBubble
SetPlayerChatBubble
========
http://wiki.sa-mp.com/wiki/SetPlayerShopName
SetPlayerShopName
=============
http://wiki.sa-mp.com/wiki/StartRecordingPlayerData
StartRecordingPlayerData
=====
http://wiki.sa-mp.com/wiki/Uudecode
Uudecode
===========
http://wiki.sa-mp.com/wiki/Valstr
Valstr
========
http://wiki.sa-mp.com/wiki/VectorSize
VectorSize
======
CALL BACKS=====

----

http://wiki.sa-mp.com/wiki/OnIncomingConnection
OnIncomingConnection
======

http://wiki.sa-mp.com/wiki/OnUnoccupiedVehicleUpdate
OnUnoccupiedVehicleUpdate
=======

I know that i'm basically posting off of samp wiki but the fact that seeing people not knowing about this, it can help them and everyone else who didn't bother reading all of the samp wiki functions, here are the main links and some very useful links i found:

1- SA-MP.CFG
2- SERVER.CFG
3- SAMP FUNCTIONS
4- SAMP CALLBACKS
5- MAIN WIKI PAGE
Hope this helped you somehow, good luck.

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>