Sziasztok!
Unalmamban alkottam egy \"OnPlayerShoot\" callback-t. Akkor hívódik meg mikor egy játékos lõ.
Használata(példa):
#include < a_samp >
#include < OnPlayerShoot >
public OnPlayerShoot( playerid, weaponid, ammo )
{
if( weaponid == 38 )
{
ResetPlayerWeapons( playerid );
SendClientMessage( playerid, -1, \"** Sajnálom a minigun itt tiltott fegyver.\");
}
return 1;
}
A hibákat kérem jelezzétek, biztos tele lesz buggal.. most próbáltam elõször készíteni ilyesmit.
Letöltés:
LetöltésSzükséges hozzá \'YSI\':
YSI letöltéseCODE:
#include <YSI\\y_hooks>
#define HOLDING(%0) \\
((newkeys & (%0)) == (%0))
#define PRESSED(%0) \\
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
forward OnPlayerShoot(playerid,weaponid,ammo);
forward F_OnPlayerConnect(playerid);
forward F_OnPlayerKeyStateChange(playerid,newkeys,oldkeys);
new bool:Lott[MAX_PLAYERS];
new loszer[MAX_PLAYERS], weap[MAX_PLAYERS];
public F_OnPlayerConnect( playerid )
{
SetTimerEx( \"Update\", 5, 1, \"i\", playerid );
SetTimerEx( \"Leker\", 5, 1, \"i\", playerid );
return 1;
}
forward Leker(playerid);
public Leker(playerid)
{
if( GetPlayerAmmo(playerid) != loszer[playerid] )
{
loszer[playerid] = GetPlayerAmmo(playerid);
}
}
hook OnPlayerConnect( playerid )
{
CallLocalFunction( \"F_OnPlayerConnect\", \"i\", playerid );
}
forward Update(playerid);
public Update(playerid)
{
{
if( loszer[playerid] == GetPlayerAmmo(playerid) )
{
Lott[playerid] = false;
}
if(loszer[playerid] > GetPlayerAmmo(playerid) && weap[playerid] == GetPlayerWeapon(playerid))
{
loszer[playerid] = GetPlayerAmmo(playerid);
Lott[playerid] = true;
if( Lott[playerid] == true)
{
CallLocalFunction( \"OnPlayerShoot\", \"iii\", playerid, weap[playerid], loszer[playerid] );
}
}
}
}
public F_OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if( PRESSED(KEY_FIRE) )
{
loszer[playerid] = GetPlayerAmmo(playerid);
weap[playerid] = GetPlayerWeapon(playerid);
}
return 1;
}
hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
CallLocalFunction( \"F_OnPlayerKeyStateChange\", \"iii\", playerid, newkeys, oldkeys );
}