[Include] New SA-MP callbacks!

Update.
  • Fixed OnPlayerFall.
  • Optimized some code.
  • Added OnPlayerSprint.
  • Removed "PLAYER_ACTION_JUMPING" and added a callback to make jumping easier to detect (OnPlayerJump).
  • Removed "GetTickCount" and added a new method of calculating ticks - NetStats_GetConnectedTime.
The new callbacks and functions:

pawn Код:
// Called when a player jumps by pressing the jump key.
public OnPlayerJump(playerid);

// Called when a player starts or stops sprinting.
public OnPlayerSprint(playerid, status);
pawn Код:
// Returns 1 if the player is jumping.
native IsPlayerJumping(playerid);

// Returns 1 if the player is sprinting.
native IsPlayerSprinting(playerid);
Hopefully the two new callbacks will be useful for scripters. Manually detecting those two things is a pain in the ass. Here's some examples:

pawn Код:
public OnPlayerJump(playerid)
{
    if(playerLegBroken[playerid])
    {
        ApplyAnimation(playerid, "GYMNASIUM", "gym_jog_falloff", 4.1, 0, 1, 1, 0, 0);
    }
    return 1;
}
pawn Код:
public OnPlayerSprint(playerid, status)
{
    if(status)
    {
        if(random(100) < 10) // 10 percent chance of the player randomly tripping from sprinting.
        {
            ApplyAnimation(playerid, "GYMNASIUM", "gym_jog_falloff", 4.1, 0, 1, 1, 0, 0);
            GameTextForPlayer(playerid, "~r~You tripped and fell!", 3000, 3);
        }
     }
     return 1;
}
Reply

Nice job! You are legend man
Reply

Nice keep it up. Goog job.
Reply

ERRORS
Код:
callbacks.inc(936) : warning 202: number of arguments does not match definition
callbacks.inc(1149) : error 025: function heading differs from prototype
Reply

Awesome use of camera mode for garage detection, I didn't even think about that!

Also are you missing a pay n spray? This is my pay n spray array, I just compared mine to yours. I didn't go IG. My data is from the original garage data from scm.

pawn Код:
new const Float:gPayNSprayData[][] = {
    {1025.05, -1024.23, 32.1}, // LS Temple
    {487.68, -1740.87, 11.13}, // LS Santa Maria
    {-1420.73, 2583.37, 55.56}, // El Quebrados
    {-1904.39, 284.97, 40.75}, // Wang Cars
    {-2425.91, 1022.33, 50.10}, // Juniper Hill
    {1975.60, 2162.16, 10.77}, // LV Redsands
    {2065.38, -1831.51, 13.25}, // Idlewood
    {-99.55, 1118.36, 19.44}, // Fort Carson
    {721.07, -455.94, 16.04}//, // Dillimore
    //{2393.74, 1493.01, 10.52} // LV Unused (Pyramid)
};
pawn Код:
enum GARAGE_MAIN {
    Float:GARAGE_AREA[6],
    Float:GARAGE_VEHICLE_SPAWN[4],
    GARAGE_DOOR,
    GARAGE_TYPE
};
new gGarages[][GARAGE_MAIN] = {
//  AREA (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax)           VEHICLE SPAWN (x,y,z,angle)   DOOR TYPE

    // Las Venturas
    {{2602.6,1438.84,9.8337,2616.4,1462.11,15.4891},     {2609.5,1450.475,9.8337,180.0},   1,      1},
    {{2389.6,1483.26,9.81843,2398.11,1497.84,15.6841},  {2393.855,1490.55,9.81843,180.0},  5,   5},
    {{2382.28,1044,9.8337,2391.14,1059.73,13.9338},  {2386.71,1051.865,9.8337,180.0},   1,        1},
    {{2449.5,695.018,10.4742,2458.31,700.227,12.9155},  {2453.905,697.6225,10.4742,270.0},  1,    18},
    {{2218.06,2448.06,-8.43807,2234.47,2467.56,-1.5463},   {2226.265,2457.81,-8.43807,90.0},  5,    35},
    {{1550.98,1155.36,8.97329,1621.82,1224.03,29.8005},   {1586.4,1189.695,8.97329,0.0},    4,    44},
    {{2002.96,2303.72,9.61706,2010.36,2317.59,13.9914},   {2006.66,2310.655,9.61706,180.0},  1,  2},
    {{1968.23,2157.88,9.59696,1983.32,2167.03,16.2367},   {1975.775,2162.455,9.59696,270.0},  1,    5},
    {{1408.65,1899.52,10.115,1417.55,1904.91,13.1693},  {1413.1,1902.215,10.115,270.0},   1,    30},
    {{1269.2,2525.14,9.80013,1278.72,2534.49,12.9784},  {1273.96,2529.815,9.80013,90.0},   1,   27},
    {{929.554,2008.59,10.115,938.452,2013.99,13.1693},  {934.003,2011.29,10.115,270.0},   1,    28},

    // San Fierro
    {{-1694.78,1033.15,44.1937,-1681.59,1038.16,47.941},   {-1688.185,1035.655,44.1937,270.0}, 1,   2},
    {{-1794.15,1429.69,4.37321,-1787.18,1441.37,14.3732},  {-1790.665,1435.53,4.37321,180.0},  1,   1},
    {{-2171.43,649.416,49.8742,-2161.79,661.778,58.1902},  {-2166.61,655.597,49.8742,90.0},   3,    1},
    {{-1790.97,1209.71,23.763,-1782.58,1221.46,28.963},   {-1786.775,1215.585,23.763,180.0},  1,    1},
    {{-2108.92,886.553,75.566,-2101.36,896.807,80.166},   {-2105.14,891.68,75.566,0.0}, 7,        39},
    {{-1652.78,647.502,0.713446,-1617.92,671.973,-6.04924}, {-1635.35,659.7375,0.713446,0.0},  4,   34},
    {{-2728.53,212.295,3.45112,-2716.36,222.669,8.68705},  {-2722.445,217.482,3.45112,90.0},  1,    5},
    {{-2735.46,60.7331,3.07005,-2725.82,72.8828,7.92155},  {-2730.64,66.80795,3.07005,0.0},   1,    1},
    {{-2454.02,-131.556,25.0886,-2442.38,-113.935,29.8006}, {-2448.2,-122.7455,25.0886,270.0},  1,  42},
    {{-1930.66,239.541,33.4274,-1941.04,251.714,38.6634},  {-1935.85,245.6275,33.4274,180.0},  1,   1},
    {{-1908.93,277.989,40.0413,-1900.11,292.353,45.539},   {-1904.52,285.171,40.0413,180.0},  1,    5},
    {{-2112.48,-21.214,34.303,-2102.48,-11.214,40.303},   {-2107.48,-16.214,34.303,90.0},   1,    1},
    {{-2043.1,118.609,27.821,-2021.91,129.609,32.821},  {-2032.505,124.109,27.821,0.0},   1,    41},
    {{-2057.35,150.803,27.8286,-2038.91,182.876,33.2286},  {-2048.13,166.8395,27.8286,90.0},  1,    1},
    {{-2430.13,1013.71,49.3413,-2421.2,1027.76,55.3413},   {-2425.665,1020.735,49.3413,0.0},  1,    5},
    {{-2699.12,821.489,49.0042,-2692.9,831.208,53.653},   {-2696.01,826.3485,49.0042,180.0},  1,    40},

    // Los Santos
    {{2502.31,-1699.36,12.4323,2508.61,-1691.01,16.5666},  {2505.46,-1695.185,12.4323,0.0},   1,    16},
    {{2056.6,-1835.9,12.5443,2071.3,-1826.97,18.5443},  {2063.95,-1831.435,12.5443,90.0},  1,   5},
    {{1352.58,-636.657,108.135,1359.02,-627.962,113.135},  {1355.8,-632.3095,108.135,18.0},   1,    32},
    {{1640.37,-1520.07,12.5118,1647.6,-1512.45,18.1245},   {1643.985,-1516.26,12.5118,180.0},  5,   1},
    {{1523.92,-1653.23,4.72837,1556.92,-1633.23,12.2284},  {1540.42,-1643.23,4.72837,180.0},  5,    33},
    {{2738.4,-2012.55,12.5759,2743.78,-2004.41,17.8299},   {2741.09,-2008.48,12.5759,0.0},   1,  1},
    {{2640.78,-2049.99,12.543,2648.96,-2039.55,16.206},   {2644.87,-2044.77,12.543,0.0},    1,    1},
    {{1873.97,-2096.55,12.487,1880.88,-2087.62,15.7681},   {1877.425,-2092.085,12.487,180.0},  5,   1},
    {{1843.91,-1858.8,12.3645,1857.1,-1853.79,16.1118},   {1850.505,-1856.295,12.3645,270.0}, 1,    2},
    {{1798.82,-2150.67,12.4283,1809.46,-2142.75,16.4347},  {1804.14,-2146.71,12.4283,270.0},  1,    1},
    {{1694.8,-2088.7,12.3636,1703,-2077.48,16.2236},     {1698.9,-2083.09,12.3636,180.0},   5,    31},
    {{491.103,-1747.55,9.45516,492.717,-1746.3,17.565},   {491.91,-1746.925,9.45516,0.0},   1,    5},
    {{319.326,-1768.93,3.35686,325.625,-1759.57,7.49114},  {322.4755,-1764.25,3.35686,180.0},  1,   17},
    {{1038.24,-1025.67,31.1027,1068.35,-995.044,39.1027},  {1053.295,-1010.357,31.1027,180.0}, 1,   1},
    {{1021.81,-1029.53,30.9081,1027.93,-1018.71,36.9081},  {1024.87,-1024.12,30.9081,180.0},  1,    5},

    // Country
    {{-103.636,1112.42,18.7017,-96.3613,1125.79,24.5489},  {-99.99865,1119.105,18.7017,180.0}, 1,   5},
    {{-364.439,1194.37,18.597,-356.214,1202.97,22.3812},   {-360.3265,1198.67,18.597,180.0},  1,    24},
    {{430.059,2542.31,15.166,442.896,2550.75,19.5951},  {436.4775,2546.53,15.166,270.0},   1,   25},
    {{-397.297,2223.17,41.3824,-389.058,2229.07,44.6359},  {-393.1775,2226.12,41.3824,285.1},  1,   1},
    {{383.843,2433.28,15.166,426.012,2476.13,24.6886},  {404.9275,2454.705,15.166,0.0},   4,    45},
    {{715.806,-462.403,14.9635,724.293,-447.29,21.4398},   {720.0495,-454.8465,14.9635,180.0}, 1,   5},
    {{2227.6,168.649,26.4635,2234.93,176.333,29.4635},  {2231.265,172.491,26.4635,180.0},  1,   29},
    {{783.155,-492.75,16.3361,789.029,-485.118,19.3361},   {786.092,-488.934,16.3361,180.0},  1,    26},
    {{-1424.11,2576.61,54.8156,-1416.85,2590.84,60.8747},  {-1420.48,2583.725,54.8156,0.0},   1,    5},
    {{-2114.42,-2462.27,29.4809,-2109.36,-2458.88,32.3474}, {-2110.38,-2462.86,29.4809,48.1},  1,   1}
};
Reply

Thanks for reminding me! I forgot the one near Santa Maria Beach.. I could've sworn I had it in there at one point before I restructured the arrays.
Reply

I'm getting a few errors too. Updated my SA:MP includes though.
Код:
foreach.inc(381) : warning 209: function "OnGameModeInit" should return a value
callbacks.inc(1153) : warning 202: number of arguments does not match definition
callbacks.inc(1282) : warning 201: redefinition of constant/macro (symbol "OnGameModeInit")
callbacks.inc(1386) : error 025: function heading differs from prototype
: error 021: symbol already defined: "OnGameModeInit"
Reply

Quote:
Originally Posted by Rocket16
Посмотреть сообщение
I'm getting a few errors too. Updated my SA:MP includes though.
Код:
foreach.inc(381) : warning 209: function "OnGameModeInit" should return a value
callbacks.inc(1153) : warning 202: number of arguments does not match definition
callbacks.inc(1282) : warning 201: redefinition of constant/macro (symbol "OnGameModeInit")
callbacks.inc(1386) : error 025: function heading differs from prototype
: error 021: symbol already defined: "OnGameModeInit"
Should be fixed now!
Reply

IsPlayerBurning(playerid) doesn't work either.
Reply

Quote:
Originally Posted by ]Rafaellos[
Посмотреть сообщение
IsPlayerBurning(playerid) doesn't work either.
IsPlayerBurning() only worked if OnPlayerStartBurn is defined in your script, but I fixed it now so it can be used externally without having to define the callback itself, which is what most people want.
Reply

Add OnPlayerBurnActor(playerid, actorid) with weaponid 18 (molotov)
Reply

Good job, those new callbacks are handy!
Reply

Any idea when this will be fixed, or what is causing it?

Код:
[00:42:42] [connection] 127.0.0.1:63404 requests connection cookie.
[00:42:43] [connection] incoming connection: 127.0.0.1:63404 id: 0
[00:42:43] [join] Cody has joined the server (0:127.0.0.1)
[00:42:49] [debug] Server crashed while executing wat.amx
[00:42:49] [debug] AMX backtrace:
[00:42:49] [debug] #0 native CallLocalFunction () [004743b0] from samp-server.exe
[00:42:49] [debug] #1 00012950 in public OnPlayerUpdate (playerid=0) at C:\xampp\htdocs\samp\pawno\include\callbacks.inc:919
[00:42:49] [debug] Native backtrace:
[00:42:49] [debug] #0 0047467c in ?? () from samp-server.exe
[00:42:49] [debug] #1 004010b6 in ?? () from samp-server.exe
[00:42:49] [debug] #2 529a9db7 in ?? () from plugins\crashdetect.DLL
[00:42:49] [debug] #3 529b58ca in ?? () from plugins\crashdetect.DLL
[00:42:49] [debug] #4 529b774f in ?? () from plugins\crashdetect.DLL
[00:42:49] [debug] #5 529b0834 in ?? () from plugins\crashdetect.DLL
[00:42:49] [debug] #6 529b591a in ?? () from plugins\crashdetect.DLL
[00:42:49] [debug] #7 52954885 in ?? () from plugins\streamer.DLL
[00:42:49] [debug] #8 0046e8d0 in ?? () from samp-server.exe
[00:42:49] [debug] #9 0048f6ab in ?? () from samp-server.exe
[00:42:49] [debug] #10 56782db3 in ?? () from plugins\mysql.DLL
[00:42:49] [debug] #11 0048d4db in ?? () from samp-server.exe
[00:42:49] [debug] #12 5c8b01f8 in ?? () from samp-server.exe
[00:42:49] [debug] #13 61750824 in ?? () from samp-server.exe
Only callbacks I use is OnPlayerPause and OnPlayerUnpause.
Reply

Quote:
Originally Posted by itsCody
Посмотреть сообщение
Any idea when this will be fixed, or what is causing it?

Код:
[00:42:42] [connection] 127.0.0.1:63404 requests connection cookie.
[00:42:43] [connection] incoming connection: 127.0.0.1:63404 id: 0
[00:42:43] [join] Cody has joined the server (0:127.0.0.1)
[00:42:49] [debug] Server crashed while executing wat.amx
[00:42:49] [debug] AMX backtrace:
[00:42:49] [debug] #0 native CallLocalFunction () [004743b0] from samp-server.exe
[00:42:49] [debug] #1 00012950 in public OnPlayerUpdate (playerid=0) at C:\xampp\htdocs\samp\pawno\include\callbacks.inc:919
[00:42:49] [debug] Native backtrace:
[00:42:49] [debug] #0 0047467c in ?? () from samp-server.exe
[00:42:49] [debug] #1 004010b6 in ?? () from samp-server.exe
[00:42:49] [debug] #2 529a9db7 in ?? () from plugins\crashdetect.DLL
[00:42:49] [debug] #3 529b58ca in ?? () from plugins\crashdetect.DLL
[00:42:49] [debug] #4 529b774f in ?? () from plugins\crashdetect.DLL
[00:42:49] [debug] #5 529b0834 in ?? () from plugins\crashdetect.DLL
[00:42:49] [debug] #6 529b591a in ?? () from plugins\crashdetect.DLL
[00:42:49] [debug] #7 52954885 in ?? () from plugins\streamer.DLL
[00:42:49] [debug] #8 0046e8d0 in ?? () from samp-server.exe
[00:42:49] [debug] #9 0048f6ab in ?? () from samp-server.exe
[00:42:49] [debug] #10 56782db3 in ?? () from plugins\mysql.DLL
[00:42:49] [debug] #11 0048d4db in ?? () from samp-server.exe
[00:42:49] [debug] #12 5c8b01f8 in ?? () from samp-server.exe
[00:42:49] [debug] #13 61750824 in ?? () from samp-server.exe
Only callbacks I use is OnPlayerPause and OnPlayerUnpause.
Yeah someone else was having this problem with this include and were blaming my include... xD
Reply

Someone should make new detection for sprinting. My idea is to use GetPlayerVelocity.
Reply

OnPlayerEmpty weapon won't work for spray can
Reply

I don't recommend using this because Emmet has left SA-MP and he isn't updating it, maybe I will release my version of Callbacks, but I am still using his AFK system.
Reply

Quote:
Originally Posted by ALiScripter
Посмотреть сообщение
I don't recommend using this because Emmet has left SA-MP and he isn't updating it, maybe I will release my version of Callbacks, but I am still using his AFK system.
Why not using these include? Its still up to date. Example file is a bit outdated (one commit) but include is in perfect shape for 0.3.7
Reply

Quote:
Originally Posted by DRIFT_HUNTER
Посмотреть сообщение
Why not using these include? Its still up to date. Example file is a bit outdated (one commit) but include is in perfect shape for 0.3.7
There are bugs in it and causes lags, I and Humza have talked about it.

EDIT: I have suffered from weird crashes.
Reply

Quote:
Originally Posted by ALiScripter
Посмотреть сообщение
There are bugs in it and causes lags, I and Humza have talked about it.

EDIT: I have suffered from weird crashes.
Use crashdetect and post crash log here.
Reply


Forum Jump:


Users browsing this thread: 8 Guest(s)