[Include] New SA-MP callbacks!
#41

I love these Callbacks
Reply
#42

Checking job functions IsPlayerPaused. Example code:
pawn Код:
CMD:pm(playerid, params[])
{
// skip the extra code
new toPlayer;
if( IsPlayerPaused( toPlayer ) ) return SendClientMessage( playerid, -1, "Player in pause" );
}
The problem is that often when the player is actually not in the pause, the message says that it is paused.
Reply
#43

Quote:
Originally Posted by PT
Посмотреть сообщение
one idea:

pawn Код:
native GetServerIP();
add that.
I'll see if I can add it, thanks. One problem is that if the server's IP isn't listed in "server.cfg", there would have to be additional parsing, which differs from the operating system of the server.

Quote:
Originally Posted by Optimus_Sprite
Посмотреть сообщение
Checking job functions IsPlayerPaused. Example code:
pawn Код:
CMD:pm(playerid, params[])
{
// skip the extra code
new toPlayer;
if( IsPlayerPaused( toPlayer ) ) return SendClientMessage( playerid, -1, "Player in pause" );
}
The problem is that often when the player is actually not in the pause, the message says that it is paused.
I'll take a look at the code, thanks.
Reply
#44

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
I'll see if I can add it, thanks. One problem is that if the server's IP isn't listed in "server.cfg", there would have to be additional parsing, which differs from the operating system of the server.
you can use the http inc to get them, from an website..
Reply
#45

Quote:
Originally Posted by PT
Посмотреть сообщение
you can use the http inc to get them, from an website..
Not recommended. The best way of doing it is to use "bind IP_HERE" in server.cfg and then use GetServerVarAsString to retrieve the IP but it's not something would fit that much in that include.
Reply
#46

EPIC, nuff said.
Reply
#47

Код:
Updates:
- Fixed a problem with IsPlayerPaused (thanks to Optimus_Sprite).
- Added additional checks to only execute code if the callback exists.
- The system now uses bit flags for optimal performance.
- Fixed a few more bugs and glitches.
And a new callback:

pawn Код:
public OnPlayerCarJack(playerid, targetid, vehicleid)
{
    return 1;
}
"playerid" is the player that jacked the vehicle, and "targetid" is the other player that got jacked.

I've also added additional checking that will only execute certain code if the callback for it exists. For instance, if "OnPlayerCrashVehicle" isn't used in the current script, the system won't detect or try to call it. This should boost up performance for most systems.
Reply
#48

Quote:
Originally Posted by feartonyb
View Post
Is it posible for OnPlayerCrashVehicle to put return 0; and vehicle won't be damaged?
I don't think so - OnPlayerCrashVehicle is only an event listener, but you could heal the vehicle with the damage detected by the callback and that'd be it.
Reply
#49

Nice... #EmmetForBetaTester2014
Reply
#50

I used this include to make a command which would show all the paused people on my server when I use that command but it returns huge amounts of time.
for example if a player is paused for 10 seconds it would show "%s is paused for 107637 seconds", where only the first two digits are the real paused time for the player.
Reply
#51

Quote:
Originally Posted by iBeast
View Post
I used this include to make a command which would show all the paused people on my server when I use that command but it returns huge amounts of time.
for example if a player is paused for 10 seconds it would show "%s is paused for 107637 seconds", where only the first two digits are the real paused time for the player.
The time is returned in milliseconds.

pawn Code:
new seconds = GetPlayerPausedTime(playerid) / 1000;
I am thinking of adding another function for getting the total HH:MM:SS of the player's paused time.
Reply
#52

ow!
Thanks, Emmet_
My Bad.
Anyways, nice include, already repped you yesterday I think.
Reply
#53

Thank you emmet, I guess I'll use some of these Functions to my server!
Reply
#54

Very good!
Reply
#55

Great work!
Reply
#56

Great include, thanks .
Reply
#57

Packet Loss function can be improved now since Kalcor made a good function called NetStats_PacketLossPercent.

Example Code (not-tested)

pawn Code:
forward OnPlayerPacketLoss(playerid, Float:PacketLost);

static
    TickPacketLoss[ MAX_PLAYERS ];

public OnPlayerUpdate(playerid)
{
    if( ( gettime() - TickPacketLoss[ playerid ] < 1 ) && ( GetPlayerPacketLoss( playerid ) >= 1.0 ) && ( IsPlayerConnected( playerid ) ) ) //called everyone 1 second.
    {
        CallLocalFunction( "OnPlayerPacketLoss", "if", playerid, GetPlayerPacketLoss(playerid) );
    }
    TickPacketLoss[ playerid ] = gettime();
    return true;
}

stock GetPlayerPacketLoss(playerid) return NetStats_PacketLossPercent(playerid), true;
Reply
#58

I was actually thinking about

pawn Код:
native OnPlayerAnimationFinish(playerid, animname[]);
But it would be hard, cuz we need to know when the animation actually finishes. I don't know if that is possible, maybe some documentation is hidden in GTA SA files, that might be useful. Honestly, that would be awesome to have that.
Reply
#59

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
I was actually thinking about

pawn Код:
native OnPlayerAnimationFinish(playerid, animname[]);
But it would be hard, cuz we need to know when the animation actually finishes. I don't know if that is possible, maybe some documentation is hidden in GTA SA files, that might be useful. Honestly, that would be awesome to have that.
It's pretty possible by getting the animation under OnPlayerUpdate or perhaps a timer and see if it's not the animation which had been called.

OT : I've never thought that this include would call the parts only if it's on use, that's really great. It also gave an idea for my future works.
Reply
#60

Quote:
Originally Posted by Kar
Посмотреть сообщение
I've made forward OnPlayerDisableCursor(playerid, lastColour);

but forward OnPlayerDisableCursor(playerid, Text:textdrawid); would either require a client sided plugin (like what iPLEOMAX did for his textdraw creation tool) or a sa-mp update with the necessary updates.

Continue to do what you are doing Emmet_!

I hope you accounted for weapon skill / UsePlayerPedAnims() in OnPlayerAntiReload!
Thanks. I added a "hovercolor" parameter to the callback in the recent update. To work around the weapon skill problem, I detect 34 shots instead of 17, and so on for other dual weapons, but in the future I might add a "GetPlayerSkillLevel" hook.

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
I was actually thinking about

pawn Код:
native OnPlayerAnimationFinish(playerid, animname[]);
But it would be hard, cuz we need to know when the animation actually finishes. I don't know if that is possible, maybe some documentation is hidden in GTA SA files, that might be useful. Honestly, that would be awesome to have that.
Not a bad idea. It's actually pretty easy lol, it can be done by deferring the timer that stores the player's animation index, and constantly checking if the player's animation index changes abruptly, and if so, call the function.

Edit: I've tested this a few times, but I need other users to confirm that it works. Download the new version from the first post and include it in any script that uses "ApplyAnimation", and compile with the snippet below:

pawn Код:
public OnPlayerAnimationFinish(playerid, animlib[], animname[]) {
    new string[64];

    format(string, sizeof(string), "Library: %s, Name: %s", animlib, animname);

    return SendClientMessage(playerid, 0xFFFFFFFF, string);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)