SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 26/01/2014, 04:01 PM   #1
Emmet_
Guest
 
Posts: n/a
Default New SA-MP callbacks!

New SA-MP callbacks

Here is a collection of useful callbacks for scripters to use. Ideas for new callbacks are welcome!

Callback list
pawn Code:
OnPlayerPause(playerid)
Description: Called when a player is paused.

OnPlayerResume(playerid, time)
Description: Called when a player has resumed.

OnPlayerHoldingKey(playerid, keys)
Description: Called when a player begins holding a specific key.

OnPlayerReleaseKey(playerid, keys)
Description: Called when a player releases a key.

OnPlayerFall(playerid, Float:damage)
Description: Called when a player falls and loses damage.

OnPlayerPacketLoss(playerid, Float:newpacket, Float:oldpacket)
Description: Called when a player experiences packet loss.

OnPlayerUseVending(playerid, type)
Description: Called when a player uses a vending machine.

OnPlayerCrashVehicle(playerid, vehicleid, Float:damage)
Description: Called when a player crashes a vehicle.

OnPlayerFPSChange(playerid, oldfps, newfps)
Description: Called when a player's FPS rate changes.

OnPlayerJackVehicle(playerid, targetid, vehicleid)
Description: Called when a player jacks another player'
s vehicle.

OnPlayerEmptyWeapon(playerid, weaponid)
Description: Called when a player depletes all ammo in a weapon.

OnPlayerFriendlyFire(playerid, targetid, weaponid)
Description: Called when a player shoots at a teammate.

OnPlayerTargetPlayer(playerid, targetid, weaponid)
Description: Called when a player targets a player with their weapon.

OnPlayerHideCursor(playerid, hovercolor)
Description: Called when a player cancels textdraw selection.

OnPlayerAntiReload(playerid, weaponid)
Description: Called when a player shoots without reloading their weapon.

OnPlayerAnimationPlay(playerid, animlib[], animname[])
Description: Called when an animation is played.

OnPlayerReloadWeapon(playerid, weaponid, ammo)
Description: Called when a player reloads their weapon.

OnPlayerActionChange(playerid, oldaction, newaction)
Description: Called when a player's action change (see action list).

OnPlayerRamPlayer(playerid, driverid, vehicleid, Float:damage)
Description: Called when a player rams another player.

OnPlayerSprayAtVehicle(playerid, vehicleid)
Description: Called wehn a player is spraying at a vehicle.

OnPlayerStartBurn(playerid)
Description: Called when a player is burning from fire.

OnPlayerStopBurn(playerid)
Description: Called when a player stops burning.

OnPlayerStartAim(playerid, weaponid)
Description: Called when a player is aiming a weapon.

OnPlayerStopAim(playerid)
Description: Called when a player stops aiming.

OnPlayerUseCamera(playerid)
Description: Called when a player snaps a picture with a camera (weapon ID: 43).

OnPlayerJump(playerid)
Description: Called when a player jumps (SHIFT key).

OnPlayerUseGarage(playerid, vehicleid, type)
Description: Called when a player uses a Pay'
n'Spray or bomb shop.

OnVehicleCreated(vehicleid, color1, color2)
Description: Called when a vehicle is created by the server.

Function list
Code:
IsPlayerPaused(playerid)
Description: Returns 1 if the player is paused.

IsPlayerSkydiving(playerid);
Description: Returns 1 if the player is skydiving.

IsPlayerSwimming(playerid)
Description: Returns 1 if the player is swimming.

IsPlayerBurning(playerid)
Description: Returns 1 if the player is burning.

IsPlayerAiming(playerid)
Description: Returns 1 if the player is aiming a weapon.

IsPlayerJumping(playerid)
Description: Returns 1 if the player is jumping.

IsPlayerNearVending(playerid, type)
Description: Returns 1 if the player is near the specified vending machine type.

IsPlayerSprayingVehicle(playerid, vehicleid)
Description: Returns 1 if the player is spraying the specified vehicle with a spraycan (weapon ID: 41).

IsPlayerNearGarage(playerid, type)
Description: Returns 1 if the player is near the specified garage type.

GetPlayerAction(playerid)
Description: Returns the player's current action.

Float:GetPlayerPacketLoss(playerid)
Description: Returns the player's packet loss.

GetPlayerPausedTime(playerid)
Description: Returns the time the player has been paused (in milliseconds).

GetPlayerFPS(playerid)
Description: Returns the player's FPS.
Action types for GetPlayerAction and OnPlayerActionChange:

pawn Code:
#define PLAYER_ACTION_NONE      0
#define PLAYER_ACTION_SHOOTING  1
#define PLAYER_ACTION_SWIMMING  2
#define PLAYER_ACTION_SKYDIVING 3

Garage types for OnPlayerUseGarage and IsPlayerNearGarage:

pawn Code:
#define GARAGE_BOMBSHOP         1
#define GARAGE_PAYNSPRAY        2

Vending machine types for OnPlayerUseVending and IsPlayerNearVending:

pawn Code:
#define VENDING_TYPE_SPRUNK     1
#define VENDING_TYPE_CANDY      2

Code examples
pawn Code:
public OnPlayerUseGarage(playerid, type)
{
    if(type == GARAGE_PAYNSPRAY)
    {
        SendClientMessage(playerid, COLOR_WHITE, "You have been charged $100 for respraying your vehicle.");
        PlayerInfo[playerid][pMoney] -= 100;
    }
    else if(type == GARAGE_BOMBSHOP)
    {
        SendClientMessage(playerid, COLOR_WHITE, "You have been charged $500 for using the bomb shop.");
        PlayerInfo[playerid][pMoney] -= 500;
    }
    return 1;
}
pawn Code:
public OnPlayerResume(playerid, time)
{
    new
        string[48];

    format(string, sizeof(string), "You've been paused for %i milliseconds.", time);
    SendClientMessage(playerid, COLOR_WHITE, string);
    return 1;
}
pawn Code:
public OnPlayerActionChange(playerid, oldaction, newaction)
{
    if (newaction == PLAYER_ACTION_SHOOTING)
    {
        SendClientMessage(playerid, COLOR_WHITE, "You are now shooting a weapon.");
    }
    else if (newaction == PLAYER_ACTION_SKYDIVING)
    {
        SendClientMessage(playerid, COLOR_WHITE, "You are now skydiving.");
    }
    else if (newaction == PLAYER_ACTION_SWIMMING)
    {
        SendClientMessage(playerid, COLOR_WHITE, "You are now swimming.");
    }
}
pawn Code:
public OnPlayerStartBurn(playerid)
{
    // Attach a fire particle to this player so other players can see them burning!
    SetPlayerAttachedObject(playerid, 0, 18691, 1);
    return 1;
}

public OnPlayerStopBurn(playerid)
{
    RemovePlayerAttachedObject(playerid, 0);
    SendClientMessage(playerid, COLOR_WHITE, "You have stopped burning.");
    return 1;
}

Download
Pastebin
GitHub

Last edited by Emmet_; 28/02/2016 at 12:45 PM.
  Reply With Quote
Old 26/01/2014, 04:06 PM   #2
Mystique
Huge Clucker
 
Mystique's Avatar
 
Join Date: Nov 2009
Posts: 460
Reputation: 13
Default Re: New SA-MP callbacks!

Looks very nice! I'll definately use some of these functions in my script.
Mystique is offline   Reply With Quote
Old 26/01/2014, 04:06 PM   #3
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,133
Reputation: 445
Default Re: New SA-MP callbacks!

Emmet for Dev. Team 2014
Abagail is offline   Reply With Quote
Old 26/01/2014, 04:34 PM   #4
iZN
High-roller
 
Join Date: Jun 2010
Posts: 2,369
Reputation: 569
Default Re: New SA-MP callbacks!

Quote:
Originally Posted by Abagail View Post
Emmet for Dev. Team 2014
wat


Good work Emmet.
__________________
iZN is offline   Reply With Quote
Old 26/01/2014, 04:34 PM   #5
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,336
Reputation: 138
Default Re: New SA-MP callbacks!

Another good work.
keep going.!
__________________
nope[IMG]http://*******/1r0SOkH_[/IMG]
•••[CLOSED]LCS•Freeroam•DM•Stunts•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
N/A176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is offline   Reply With Quote
Old 26/01/2014, 04:34 PM   #6
Jimmy0wns
Gangsta
 
Join Date: Sep 2012
Location: Netherlands
Posts: 686
Reputation: 208
Default Re: New SA-MP callbacks!

Those are very usefull, great job Emmet!
Jimmy0wns is offline   Reply With Quote
Old 26/01/2014, 04:41 PM   #7
Ryan_Bowe
Huge Clucker
 
Join Date: Jul 2012
Location: United States
Posts: 218
Reputation: 16
Default Re: New SA-MP callbacks!

....

Last edited by Ryan_Bowe; 02/01/2015 at 02:05 PM.
Ryan_Bowe is offline   Reply With Quote
Old 26/01/2014, 04:52 PM   #8
PT
Godfather
 
PT's Avatar
 
Join Date: Nov 2012
Location: Europe
Posts: 7,180
Reputation: 803
Default Re: New SA-MP callbacks!

This is very usefull nice job Emmet
PT is offline   Reply With Quote
Old 26/01/2014, 04:53 PM   #9
Jimmy0wns
Gangsta
 
Join Date: Sep 2012
Location: Netherlands
Posts: 686
Reputation: 208
Default Re: New SA-MP callbacks!

The onplayerfall one, wouldn't that work for an anti airbreak?
Jimmy0wns is offline   Reply With Quote
Old 26/01/2014, 05:21 PM   #10
QuaTTrO
Gangsta
 
QuaTTrO's Avatar
 
Join Date: Aug 2009
Posts: 516
Reputation: 75
Default Re: New SA-MP callbacks!

Suggestion:
pawn Code:
stock GetPlayerInactiveTime(playerid)
There is 'time' param in the OnPlayerResume so why not add this as a function. Anyway good include i will use it in my gamemode (Less work making AFK system )
QuaTTrO 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
Using callbacks more then once Admigo Scripting Help 5 29/09/2013 02:32 PM
SA-MP Callbacks Shinki Help Archive 0 03/06/2011 08:20 PM
New Callbacks? Rokzlive Help Archive 4 12/03/2011 05:10 PM
Need help with some callbacks. Rokzlive Help Archive 2 15/12/2010 08:53 PM


All times are GMT. The time now is 03:24 AM.


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