Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Marcas de objetivo
- Jelly23
- */
- #include <a_samp>
- /*Configuração*/
- #define OM_USAR_STREAMER (false)
- #define OM_USAR_FOREACH (false)
- #define OM_MAX_GROUPS (100)
- /*Enumerador*/
- enum OM_GROUPS_INF
- {
- OM_GROUP_TIMER,
- OM_GROUP_MARKER,
- OM_GROUP_EXISTS
- };
- /*Vars*/
- static
- OM_Group[MAX_PLAYERS], //Grupo do jogador.
- OM_Marca[MAX_PLAYERS], //Marcas globais por jogador.
- OM_Timer[MAX_PLAYERS], //Timer de marcas globais.
- OM_Timer_Player[MAX_PLAYERS][MAX_PLAYERS], //Timer de marcas por jogador.
- OM_Marca_Player[MAX_PLAYERS][MAX_PLAYERS], //Marcas por jogador.
- OM_GRINFO[OM_MAX_GROUPS][OM_GROUPS_INF]; //Enumerador de grupos.
- /*Callback interna*/
- forward OM_DestroyObjectiveMarker(playerid, type, attachid);
- /*Tipos De Marcas*/
- #define OM_TYPE_GLOBAL (0)
- #define OM_TYPE_PLAYER (1)
- #define OM_TYPE_GROUPS (2)
- public OnPlayerDisconnect(playerid,reason)
- {
- OM_Group[playerid] = -1;
- DestroyObjectiveMarker(playerid);
- #if defined OM_OnPlayerDisconnect
- return OM_OnPlayerDisconnect(playerid,reason);
- #else
- return 1;
- #endif
- }
- //Callback de uso interno
- public OM_DestroyObjectiveMarker(playerid, type, attachid)
- {
- if(type == OM_TYPE_GLOBAL)
- {
- if(!IsPlayerConnected(playerid)) return 0;
- #if OM_USAR_STREAMER true
- if(IsValidDynamicObject(OM_Marca[playerid]))
- {
- DestroyDynamicObject(OM_Marca[playerid]);
- }
- #else
- if(IsValidObject(OM_Marca[playerid]))
- {
- DestroyObject(OM_Marca[playerid]);
- }
- #endif
- }
- else if(type == OM_TYPE_PLAYER)
- {
- if(!IsPlayerConnected(playerid)) return 0;
- if(IsValidPlayerObject(playerid, OM_Marca_Player[playerid][attachid])) DestroyPlayerObject(playerid, OM_Marca_Player[playerid][attachid]);
- }
- else
- {
- if(!IsPlayerConnected(attachid)) return 0;
- #if OM_USAR_FOREACH true
- foreach(new i: Player)
- {
- if(OM_Group[i] == playerid)
- {
- if(IsValidPlayerObject(i, OM_Marca_Player[i][attachid])) DestroyPlayerObject(i, OM_Marca_Player[i][attachid]);
- }
- }
- #else
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(OM_Group[i] == playerid)
- {
- if(IsValidPlayerObject(i, OM_Marca_Player[i][attachid])) DestroyPlayerObject(i, OM_Marca_Player[i][attachid]);
- }
- }
- }
- #endif
- }
- return 1;
- }
- //Funções Globais
- stock CreateObjectiveMarker(playerid, color= -55, time = 0)
- {
- if(!IsPlayerConnected(playerid)) return 0;
- #if OM_USAR_STREAMER true
- if(IsValidDynamicObject(OM_Marca[playerid]))
- {
- DestroyDynamicObject(OM_Marca[playerid]);
- }
- #else
- if(IsValidObject(OM_Marca[playerid]))
- {
- DestroyObject(OM_Marca[playerid]);
- }
- #endif
- if(color == -55) color = GetPlayerColor(playerid);
- if(time > 0)
- {
- OM_Timer[playerid] = SetTimerEx("OM_DestroyObjectiveMarker", time, false, "ii", playerid, OM_TYPE_GLOBAL);
- }
- #if OM_USAR_STREAMER true
- OM_Marca[playerid] = CreateDynamicObject(19198, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- SetDynamicObjectMaterial(OM_Marca[playerid], 0, -1, "none", "none", color >>> 8 | color << 24);
- AttachDynamicObjectToPlayer(OM_Marca[playerid], playerid, 0.0, 0.0, 2.3, 0.000000, 0.000000,0.000000);
- #else
- OM_Marca[playerid] = CreateObject(19198, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
- SetObjectMaterial(OM_Marca[playerid], 0, -1, "none", "none", color >>> 8 | color << 24);
- AttachObjectToPlayer(OM_Marca[playerid], playerid, 0.0, 0.0, 2.3, 0.000000, 0.000000,0.000000);
- #endif
- return 1;
- }
- stock DestroyObjectiveMarker(playerid)
- {
- if(!IsPlayerConnected(playerid)) return 0;
- #if OM_USAR_STREAMER true
- if(IsValidDynamicObject(OM_Marca[playerid]))
- {
- DestroyDynamicObject(OM_Marca[playerid]);
- }
- #else
- if(IsValidObject(OM_Marca[playerid]))
- {
- DestroyObject(OM_Marca[playerid]);
- }
- #endif
- return 1;
- }
- stock IsValidMarker(playerid)
- {
- if(!IsPlayerConnected(playerid)) return 0;
- #if OM_USAR_STREAMER true
- if(IsValidDynamicObject(OM_Marca[playerid]))
- #else
- if(IsValidObject(OM_Marca[playerid]))
- #endif
- {
- return 1;
- }
- else return 0;
- }
- //Funções de grupos
- stock CreateObjectiveMarkerGroup(id, marker_color)
- {
- if(0 < id > OM_MAX_GROUPS || OM_GRINFO[id][OM_GROUP_EXISTS]) return 0;
- OM_GRINFO[id][OM_GROUP_MARKER] = marker_color;
- OM_GRINFO[id][OM_GROUP_EXISTS] = 1;
- return 1;
- }
- stock DestroyObjectiveMarkerGroup(id)
- {
- if(0 < id > OM_MAX_GROUPS) return 0;
- OM_GRINFO[id][OM_GROUP_EXISTS] = 0;
- #if OM_USAR_FOREACH true
- foreach(new i: Player)
- {
- if(OM_Group[i] == id)
- {
- OM_Group[i] = -1;
- }
- }
- #else
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(OM_Group[i] == id)
- {
- OM_Group[i] = -1;
- }
- }
- }
- #endif
- return 1;
- }
- stock AddPlayerToObjectiveGroup(playerid, group_id)
- {
- if(0 < group_id > OM_MAX_GROUPS || !OM_GRINFO[group_id][OM_GROUP_EXISTS]) return 0;
- OM_Group[playerid] = group_id;
- return 1;
- }
- stock RemovePlayerFromObjectiveGroup(playerid)
- {
- OM_Group[playerid] = -1;
- return 1;
- }
- stock DestroyObjectiveMarkerForGroup(groupid, attachid)
- {
- if(!IsPlayerConnected(attachid)) return 0;
- #if OM_USAR_FOREACH true
- foreach(new i: Player)
- {
- if(OM_Group[i] == groupid)
- {
- if(IsValidPlayerObject(i, OM_Marca_Player[i][attachid])) DestroyPlayerObject(i, OM_Marca_Player[i][attachid]);
- }
- }
- #else
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(OM_Group[i] == groupid)
- {
- if(IsValidPlayerObject(i, OM_Marca_Player[i][attachid])) DestroyPlayerObject(i, OM_Marca_Player[i][attachid]);
- }
- }
- }
- #endif
- return 1;
- }
- stock CreateObjectiveMarkerForGroup(groupid, attachid, color= -55, time = 0)
- {
- if(!IsPlayerConnected(attachid) || 0 < groupid > OM_MAX_GROUPS || !OM_GRINFO[groupid][OM_GROUP_EXISTS]) return 0;
- if(color == -55) color = OM_GRINFO[groupid][OM_GROUP_MARKER];
- if(time > 0)
- {
- OM_GRINFO[groupid][OM_GROUP_TIMER] = SetTimerEx("OM_DestroyObjectiveMarker", time, false, "iii", groupid, OM_TYPE_GROUPS, attachid);
- }
- #if OM_USAR_FOREACH true
- foreach(new i: Player)
- {
- if(OM_Group[i] == groupid)
- {
- if(IsValidPlayerObject(i, OM_Marca_Player[i][attachid])) DestroyPlayerObject(i, OM_Marca_Player[i][attachid]);
- OM_Marca_Player[i][attachid] = CreatePlayerObject(i, 19198, 0, 0, 0, 0, 0, 0);
- SetPlayerObjectMaterial(i, OM_Marca_Player[i][attachid], 0, -1, "none", "none", color >>> 8 | color << 24);
- AttachPlayerObjectToPlayer(i, OM_Marca_Player[i][attachid], attachid, 0.0, 0.0, 2.3, 0, 0, 0);
- }
- }
- #else
- for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(OM_Group[i] == groupid)
- {
- if(IsValidPlayerObject(i, OM_Marca_Player[i][attachid])) DestroyPlayerObject(i, OM_Marca_Player[i][attachid]);
- OM_Marca_Player[i][attachid] = CreatePlayerObject(i, 19198, 0, 0, 0, 0, 0, 0);
- SetPlayerObjectMaterial(i, OM_Marca_Player[i][attachid], 0, -1, "none", "none", color >>> 8 | color << 24);
- AttachPlayerObjectToPlayer(i, OM_Marca_Player[i][attachid], attachid, 0.0, 0.0, 2.3, 0, 0, 0);
- }
- }
- }
- #endif
- return 1;
- }
- //Funções por Player
- stock CreateObjectiveMarkerForPlayer(playerid, attachid, color= -55, time = 0)
- {
- if(!IsPlayerConnected(playerid) || !IsPlayerConnected(attachid)) return 0;
- if(IsValidPlayerObject(playerid, OM_Marca_Player[playerid][attachid])) DestroyPlayerObject(playerid, OM_Marca_Player[playerid][attachid]);
- if(color == -55) color = GetPlayerColor(attachid);
- if(time > 0)
- {
- OM_Timer_Player[playerid][attachid] = SetTimerEx("OM_DestroyObjectiveMarker", time, false, "iii", playerid, OM_TYPE_PLAYER, attachid);
- }
- OM_Marca_Player[playerid][attachid] = CreatePlayerObject(playerid, 19198, 0, 0, 0, 0, 0, 0);
- SetPlayerObjectMaterial(playerid, OM_Marca_Player[playerid][attachid], 0, -1, "none", "none", color >>> 8 | color << 24);
- AttachPlayerObjectToPlayer(playerid, OM_Marca_Player[playerid][attachid], attachid, 0.0, 0.0, 2.3, 0, 0, 0);
- return 1;
- }
- stock DestroyObjectiveMarkerForPlayer(playerid, attachid)
- {
- if(!IsPlayerConnected(playerid)) return 0;
- if(IsValidPlayerObject(playerid, OM_Marca_Player[playerid][attachid])) DestroyPlayerObject(playerid, OM_Marca_Player[playerid][attachid]);
- return 1;
- }
- stock IsValidPlayerMarker(playerid, attachid)
- {
- if(!IsPlayerConnected(playerid)) return 0;
- if(IsValidPlayerObject(playerid, OM_Marca_Player[playerid][attachid])) return 1;
- return 0;
- }
- #if defined _ALS_OnPlayerDisconnect
- #undef OnPlayerDisconnect
- #else
- #define _ALS_OnPlayerDisconnect
- #endif
- #define OnPlayerDisconnect OM_OnPlayerDisconnect
- #if defined OM_OnPlayerDisconnect
- forward OM_OnPlayerDisconnect(playerid, reason);
- #endif
Advertisement
Add Comment
Please, Sign In to add comment