-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleIcons.inc
More file actions
145 lines (119 loc) · 3.73 KB
/
SimpleIcons.inc
File metadata and controls
145 lines (119 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// by Scottas https://github.com/ScottasM/SAMP-SimpleIcons
#include <a_samp>
#include <YSI\y_iterate>
#define MAX_ICONS 101
enum IconEnum {
bool:created[MAX_ICONS],
Float:IposX[MAX_ICONS],
Float:IposY[MAX_ICONS],
Float:IposZ[MAX_ICONS],
Float:Idist[MAX_ICONS],
ITime[MAX_ICONS],
};
new Iterator:Icons[MAX_PLAYERS]<100>;
new IconData[MAX_PLAYERS][IconEnum];
forward SetIconDistance(playerid,iconid,Float:distance);
forward SetIconTimeout(playerid,iconid,seconds);
public OnGameModeInit(){
SetTimer("CheckIcons",1000,true);
#if defined sp_OnGameModeInit
sp_OnGameModeInit();
#endif
return 1;
}
stock sp_SetPlayerMapIcon(playerid, iconid, Float:x, Float:y, Float:z, markertype, color, style = MAPICON_LOCAL){
DeleteSimpleIcon(playerid,iconid);
IconData[playerid][created][iconid]= true;
IconData[playerid][IposX][iconid] = x;
IconData[playerid][IposY][iconid] = y;
IconData[playerid][IposZ][iconid] = z;
Iter_Add(Icons[playerid],iconid);
return SetPlayerMapIcon(playerid, iconid, Float:x, Float:y, Float:z, markertype, color, style = MAPICON_LOCAL);
}
stock sp_RemovePlayerMapIcon(playerid, iconid){
Iter_Remove(Icons[playerid],iconid);
IconData[playerid][created][iconid] = false;
IconData[playerid][Idist][iconid] = 0.0;
IconData[playerid][ITime][iconid] = 0;
RemovePlayerMapIcon(playerid, iconid);
return RemovePlayerMapIcon(playerid, iconid);
}
public OnPlayerDisconnect(playerid,reason){
for(new i = 0;i<MAX_ICONS;i++){
DeleteSimpleIcon(playerid,i);
}
#if defined sp_OnPlayerDisconnect
sp_OnPlayerDisconnect(playerid,reason);
#endif
return 1;
}
public SetIconDistance(playerid,iconid,Float:distance){
if(IconData[playerid][created][iconid] == false || distance < 0)
return 0;
IconData[playerid][Idist][iconid] = distance;
return 1;
}
public SetIconTimeout(playerid,iconid,seconds){
if(IconData[playerid][created][iconid] == false || seconds < 0)
return 0;
if(seconds == 0)
IconData[playerid][ITime][iconid] = 0;
else IconData[playerid][ITime][iconid] = gettime() + seconds;
return 1;
}
forward CheckIcons();
public CheckIcons(){
foreach(new i : Player){
foreach(new j : Icons[i]){
if(IconData[i][ITime][j] > 0 && IconData[i][ITime][j] <= gettime()){
j = DeleteSimpleIcon(i,j);
continue;
}
if(IconData[i][Idist][j] > 0){
if(GetPlayerDistanceFromPoint(i,IconData[i][IposX][j],IconData[i][IposY][j],IconData[i][IposZ][j]) <= IconData[i][Idist][j]){
j = DeleteSimpleIcon(i,j);
continue;
}
}
}
}
}
DeleteSimpleIcon(playerid,id){
new prev;
Iter_SafeRemove(Icons[playerid],id,prev);
IconData[playerid][created][id] = false;
IconData[playerid][Idist][id] = 0.0;
IconData[playerid][ITime][id] = 0;
RemovePlayerMapIcon(playerid, id);
return prev;
}
#if defined _ALS_SetPlayerMapIcon
#undef SetPlayerMapIcon
#else
#define _ALS_SetPlayerMapIcon
#endif
#define SetPlayerMapIcon sp_SetPlayerMapIcon
#if defined _ALS_RemovePlayerMapIcon
#undef RemovePlayerMapIcon
#else
#define _ALS_RemovePlayerMapIcon
#endif
#define RemovePlayerMapIcon sp_RemovePlayerMapIcon
#if defined _ALS_OnGameModeInit
#undef OnGameModeInit
#else
#define _ALS_OnGameModeInit
#endif
#define OnGameModeInit sp_OnGameModeInit
#if defined _ALS_OnPlayerDisconnect
#undef OnPlayerDisconnect
#else
#define _ALS_OnPlayerDisconnect
#endif
#define OnPlayerDisconnect sp_OnPlayerDisconnect
#if defined sp_OnGameModeInit
forward sp_OnGameModeInit();
#endif
#if defined sp_OnPlayerDisconnect
forward sp_OnPlayerDisconnect();
#endif