Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- OnPlayerAssist - By: [J]ulian.
- v0.0.1 - 16/09/2014
- - Lanzamiento inicial.
- v0.0.2 - 17/09/2014
- - Se corrigió un error donde el asesino también se llamaba como asistente.
- v0.0.3 - 06/11/2014
- - Se corrigió un error donde la información de asistencia se borraba antes de ser enviada.
- Requerido:
- - y_hooks: http://forum.sa-mp.com/showthread.php?t=166016
- */
- #include <YSI\y_hooks>
- forward OnPlayerAssist(playerid, deadid, Float:damage, time, bullets);
- /*
- native ResetAssistInfo(playerid = INVALID_PLAYER_ID, userid = INVALID_PLAYER_ID);
- native SetPlayerAssistInfo(playerid, userid, Float:damage, time, bullets);
- native GetPlayerAssistInfo(playerid, userid, &Float:damage, &time, &bullets);
- */
- enum ASSIST_INFO {
- Float:DAMAGE,
- TIME,
- BULLETS
- }
- new AssistInfo[MAX_PLAYERS][MAX_PLAYERS][ASSIST_INFO];
- hook OnPlayerConnect(playerid)
- {
- for(new i = 0; i != GetMaxPlayers(); i++)
- {
- ResetAssistInfo(i, playerid);
- ResetAssistInfo(playerid, i);
- }
- return 1;
- }
- hook OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
- {
- if(hittype == BULLET_HIT_TYPE_PLAYER)
- {
- AssistInfo[playerid][hitid][BULLETS]++;
- }
- return 1;
- }
- hook OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
- {
- if(playerid != INVALID_PLAYER_ID && damagedid != INVALID_PLAYER_ID)
- {
- AssistInfo[playerid][damagedid][DAMAGE] += amount;
- AssistInfo[playerid][damagedid][TIME] = gettime();
- }
- return 1;
- }
- hook OnPlayerDeath(playerid, killerid, reason)
- {
- for(new i = 0, e = GetMaxPlayers(); i != e; i++)
- {
- if(AssistInfo[i][playerid][BULLETS] != 0)
- {
- if(killerid != i)
- {
- CallLocalFunction("OnPlayerAssist", "iifii", i, playerid, AssistInfo[i][playerid][DAMAGE], (gettime()-AssistInfo[i][playerid][TIME]), AssistInfo[i][playerid][BULLETS]);
- }
- ResetAssistInfo(i, playerid);
- }
- }
- for(new i = 0, e = GetMaxPlayers(); i != e; i++)
- {
- if(AssistInfo[playerid][i][BULLETS] != 0)
- {
- ResetAssistInfo(playerid, i);
- }
- }
- return 1;
- }
- stock ResetAssistInfo(playerid = INVALID_PLAYER_ID, userid = INVALID_PLAYER_ID)
- {
- if(playerid == INVALID_PLAYER_ID && userid == INVALID_PLAYER_ID)
- {
- for(new i = 0, e = GetMaxPlayers(); i != e; i++)
- {
- for(new u = 0, f = GetMaxPlayers(); u != f; u++)
- {
- AssistInfo[i][u][DAMAGE] = 0;
- AssistInfo[i][u][TIME] = 0;
- AssistInfo[i][u][BULLETS] = 0;
- AssistInfo[u][i][DAMAGE] = 0;
- AssistInfo[u][i][TIME] = 0;
- AssistInfo[u][i][BULLETS] = 0;
- }
- }
- return 1;
- }
- AssistInfo[playerid][userid][DAMAGE] = 0;
- AssistInfo[playerid][userid][TIME] = 0;
- AssistInfo[playerid][userid][BULLETS] = 0;
- return 1;
- }
- stock SetPlayerAssistInfo(playerid, userid, Float:damage, time, bullets)
- {
- if(playerid != INVALID_PLAYER_ID && userid != INVALID_PLAYER_ID)
- {
- if(IsPlayerConnected(playerid) && IsPlayerConnected(userid))
- {
- AssistInfo[playerid][userid][DAMAGE] = damage;
- AssistInfo[playerid][userid][TIME] = gettime()+time;
- AssistInfo[playerid][userid][BULLETS] = bullets;
- }
- }
- return 1;
- }
- stock GetPlayerAssistInfo(playerid, userid, &Float:damage, &time, &bullets)
- {
- if(playerid != INVALID_PLAYER_ID && userid != INVALID_PLAYER_ID)
- {
- if(IsPlayerConnected(playerid) && IsPlayerConnected(userid))
- {
- damage = AssistInfo[playerid][userid][DAMAGE];
- time = AssistInfo[playerid][userid][TIME];
- bullets = AssistInfo[playerid][userid][BULLETS];
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement