SHOW:
|
|
- or go back to the newest paste.
| 1 | ||
| 2 | #define FILTERSCRIPT | |
| 3 | ||
| 4 | #include <a_samp> | |
| 5 | #define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 | |
| 6 | ||
| 7 | #define COLOR_PINK 0xFF00FFFF | |
| 8 | #define COLOR_BLUE 0x006AFFFF | |
| 9 | ||
| 10 | #define COLOR_GREEN 0x00FF54FF | |
| 11 | #define COLOR_RED 0xFF2100FF | |
| 12 | ||
| 13 | new Float:XX; | |
| 14 | new Float:YY; | |
| 15 | new Float:ZZ; | |
| 16 | ||
| 17 | new event = 0; | |
| 18 | new intID; | |
| 19 | new joinable = 0; | |
| 20 | new joined[MAX_PLAYERS] = 0; | |
| 21 | ||
| 22 | new etimer; | |
| 23 | ||
| 24 | public OnFilterScriptInit() | |
| 25 | {
| |
| 26 | print("\n--------------------------------------");
| |
| 27 | print("Event system by [AK]Nazgul");
| |
| 28 | print("--------------------------------------\n");
| |
| 29 | return 1; | |
| 30 | } | |
| 31 | ||
| 32 | public OnFilterScriptExit() | |
| 33 | {
| |
| 34 | return 1; | |
| 35 | } | |
| 36 | ||
| 37 | ||
| 38 | ||
| 39 | ||
| 40 | ||
| 41 | public OnPlayerDeath(playerid, killerid, reason) | |
| 42 | {
| |
| 43 | joined[playerid] = 0; | |
| 44 | return 1; | |
| 45 | } | |
| 46 | ||
| 47 | ||
| 48 | ||
| 49 | public OnPlayerCommandText(playerid, cmdtext[]) | |
| 50 | {
| |
| 51 | dcmd(event, 5, cmdtext); | |
| 52 | dcmd(eweapon, 7, cmdtext); | |
| 53 | dcmd(winner, 6, cmdtext); | |
| 54 | - | |
| 54 | + | dcmd(start, 5, cmdtext); |
| 55 | - | if(strcmp("/start",cmdtext,true,10) == 0)
|
| 55 | + | dcmd(join, 4, cmdtext); |
| 56 | dcmd(eventover, 9, cmdtext); | |
| 57 | return 0; | |
| 58 | } | |
| 59 | - | for(new i = 0; i<MAX_PLAYERS; i++) |
| 59 | + | |
| 60 | //=======================================dcmd================================= | |
| 61 | - | TogglePlayerControllable(i,true); |
| 61 | + | |
| 62 | - | GameTextForAll("~g~EVENT STARTS",2000,3);
|
| 62 | + | dcmd_event(playerid,params[]) |
| 63 | {
| |
| 64 | if(event == 0) | |
| 65 | {
| |
| 66 | if(IsPlayerAdmin(playerid)) | |
| 67 | {
| |
| 68 | new message33[64]; | |
| 69 | if(sscanf(params,"s",message33)) return SendClientMessage(playerid,COLOR_RED,"Usage: /event [name]"); | |
| 70 | - | if(strcmp("/join", cmdtext, true, 10) ==0)
|
| 70 | + | new string[128]; |
| 71 | - | {
|
| 71 | + | format(string,sizeof(string),"~g~ %s has started. ~n~ ~y~Type /join to join the event",message33); |
| 72 | - | if(joinable == 1 && joined[playerid] == 0) |
| 72 | + | GameTextForAll(string,10000,3); |
| 73 | SendClientMessageToAll(COLOR_GREEN,"You have 1 minute to join"); | |
| 74 | etimer = SetTimer("Eventtimer",60000,false);
| |
| 75 | event = 1; | |
| 76 | GetPlayerPos(playerid,XX,YY,ZZ); | |
| 77 | intID = GetPlayerInterior(playerid); | |
| 78 | joinable = 1; | |
| 79 | return 1; | |
| 80 | } | |
| 81 | else{SendClientMessage(playerid,COLOR_RED,"You can't use this command!"); return 1;}
| |
| 82 | } | |
| 83 | else if(event == 1) | |
| 84 | {
| |
| 85 | SendClientMessage(playerid,COLOR_PINK,"An event is already running!"); | |
| 86 | return 1; | |
| 87 | } | |
| 88 | ||
| 89 | } | |
| 90 | - | if(strcmp("/eventover",cmdtext, true, 10) ==0)
|
| 90 | + | |
| 91 | dcmd_join(playerid,params[]) | |
| 92 | {
| |
| 93 | if(joinable == 1 && joined[playerid] == 0) | |
| 94 | {
| |
| 95 | ||
| 96 | SetPlayerPos(playerid, XX, YY, ZZ); | |
| 97 | SetPlayerInterior(playerid,intID); | |
| 98 | TogglePlayerControllable(playerid,false); | |
| 99 | ResetPlayerWeapons(playerid); | |
| 100 | SetPlayerHealth(playerid,100); | |
| 101 | joined[playerid] = 1; | |
| 102 | SendClientMessage(playerid,COLOR_BLUE,"You have joined the event."); | |
| 103 | return 1; | |
| 104 | } | |
| 105 | else if(joinable == 0 || event == 0) | |
| 106 | {
| |
| 107 | SendClientMessage(playerid,COLOR_BLUE,"There are no events or the current event is already running"); | |
| 108 | return 1; | |
| 109 | } | |
| 110 | ||
| 111 | } | |
| 112 | - | |
| 112 | + | dcmd_eventover(playerid,params[]) |
| 113 | - | |
| 113 | + | |
| 114 | - | |
| 114 | + | |
| 115 | {
| |
| 116 | event = 0; | |
| 117 | KillTimer(etimer); | |
| 118 | SendClientMessageToAll(COLOR_BLUE,"The event has ended!"); | |
| 119 | for(new i = 0;i<MAX_PLAYERS; i++) | |
| 120 | - | dcmd_event(playerid,params[]) |
| 120 | + | |
| 121 | ||
| 122 | - | if(event == 0) |
| 122 | + | |
| 123 | - | {
|
| 123 | + | |
| 124 | ||
| 125 | joined[i] = 0; | |
| 126 | - | new message33[64]; |
| 126 | + | |
| 127 | - | if(sscanf(params,"s",message33)) return SendClientMessage(playerid,COLOR_RED,"Usage: /event [name]"); |
| 127 | + | |
| 128 | - | new string[128]; |
| 128 | + | |
| 129 | - | format(string,sizeof(string),"~g~ %s has started. ~n~ ~y~Type /join to join the event",message33); |
| 129 | + | |
| 130 | - | GameTextForAll(string,10000,3); |
| 130 | + | |
| 131 | - | SendClientMessageToAll(COLOR_GREEN,"You have 1 minute to join"); |
| 131 | + | |
| 132 | - | etimer = SetTimer("Eventtimer",60000,false);
|
| 132 | + | |
| 133 | - | event = 1; |
| 133 | + | |
| 134 | - | GetPlayerPos(playerid,XX,YY,ZZ); |
| 134 | + | |
| 135 | - | intID = GetPlayerInterior(playerid); |
| 135 | + | dcmd_start(playerid,params[]) |
| 136 | - | joinable = 1; |
| 136 | + | |
| 137 | - | return 1; |
| 137 | + | |
| 138 | - | } |
| 138 | + | |
| 139 | if(event == 1) | |
| 140 | {
| |
| 141 | - | else if(event == 1) |
| 141 | + | for(new i = 0; i<MAX_PLAYERS; i++) |
| 142 | - | {
|
| 142 | + | {
|
| 143 | - | SendClientMessage(playerid,COLOR_PINK,"An event is already running!"); |
| 143 | + | TogglePlayerControllable(i,true); |
| 144 | - | return 1; |
| 144 | + | GameTextForAll("~g~EVENT STARTS",2000,3);
|
| 145 | ||
| 146 | } | |
| 147 | return 1; | |
| 148 | - | dcmd_eweapon(playerid,params[]) |
| 148 | + | |
| 149 | else{SendClientMessage(playerid,COLOR_RED,"There is no event running."); return 1;}
| |
| 150 | - | if(IsPlayerAdmin(playerid)) |
| 150 | + | |
| 151 | } | |
| 152 | - | new wID; |
| 152 | + | |
| 153 | - | if(sscanf(params,"i",wID)) return SendClientMessage(playerid,COLOR_RED,"Usage: /eweapon [weaponid]"); |
| 153 | + | |
| 154 | - | for(new i = 0; i<MAX_PLAYERS; i++) |
| 154 | + | |
| 155 | dcmd_eweapon(playerid,params[]) | |
| 156 | - | if(joined[i]==1) |
| 156 | + | |
| 157 | if(IsPlayerAdmin(playerid)) | |
| 158 | - | GivePlayerWeapon(i,wID,9999); |
| 158 | + | |
| 159 | new wID; | |
| 160 | if(sscanf(params,"i",wID)) return SendClientMessage(playerid,COLOR_RED,"Usage: /eweapon [weaponid]"); | |
| 161 | for(new i = 0; i<MAX_PLAYERS; i++) | |
| 162 | - | return 1; |
| 162 | + | |
| 163 | if(joined[i]==1) | |
| 164 | - | else{SendClientMessage(playerid,COLOR_RED,"You can't use this command!"); return 1;}
|
| 164 | + | |
| 165 | GivePlayerWeapon(i,wID,9999); | |
| 166 | - | dcmd_winner(playerid,params[]) |
| 166 | + | |
| 167 | } | |
| 168 | - | if(event == 1) |
| 168 | + | |
| 169 | return 1; | |
| 170 | } | |
| 171 | else{SendClientMessage(playerid,COLOR_RED,"You can't use this command!"); return 1;}
| |
| 172 | - | new price, winner; |
| 172 | + | |
| 173 | - | if(sscanf(params,"ui",winner,price)) return SendClientMessage(playerid,COLOR_RED,"Usage: /winner [ID] [Price]"); |
| 173 | + | dcmd_winner(playerid,params[]) |
| 174 | - | new str[128]; |
| 174 | + | |
| 175 | - | format(str,128,"{40E0D0}%s (%i) has won the event, and gained %d",PlayerName(winner),winner,price);
|
| 175 | + | if(event == 1) |
| 176 | - | SendClientMessageToAll(-1,str); |
| 176 | + | |
| 177 | - | GivePlayerMoney(winner,price); |
| 177 | + | if(IsPlayerAdmin(playerid)) |
| 178 | {
| |
| 179 | new price, winner; | |
| 180 | if(sscanf(params,"ui",winner,price)) return SendClientMessage(playerid,COLOR_RED,"Usage: /winner [ID] [Price]"); | |
| 181 | new str[128]; | |
| 182 | - | else{SendClientMessage(playerid,COLOR_RED,"There is no event running."); return 1;}
|
| 182 | + | format(str,128,"{40E0D0}%s (%i) has won the event, and gained %d",PlayerName(winner),winner,price);
|
| 183 | SendClientMessageToAll(-1,str); | |
| 184 | GivePlayerMoney(winner,price); | |
| 185 | - | forward Eventtimer(playerid); |
| 185 | + | return 1; |
| 186 | - | public Eventtimer(playerid) |
| 186 | + | |
| 187 | else{SendClientMessage(playerid,COLOR_RED,"You can't use this command!"); return 1;}
| |
| 188 | - | joinable = 0; |
| 188 | + | |
| 189 | - | SendClientMessageToAll(COLOR_BLUE,"The event can no longer be joined!"); |
| 189 | + | else{SendClientMessage(playerid,COLOR_RED,"There is no event running."); return 1;}
|
| 190 | } | |
| 191 | ||
| 192 | forward Eventtimer(playerid); | |
| 193 | public Eventtimer(playerid) | |
| 194 | {
| |
| 195 | joinable = 0; | |
| 196 | SendClientMessageToAll(COLOR_BLUE,"The event can no longer be joined!"); | |
| 197 | } | |
| 198 | ||
| 199 | //============================================================================ | |
| 200 | ||
| 201 | stock PlayerName(playerid) | |
| 202 | {
| |
| 203 | new name[MAX_PLAYER_NAME]; | |
| 204 | GetPlayerName(playerid,name,sizeof(name)); return name; | |
| 205 | } | |
| 206 | stock sscanf(string[], format[], {Float,_}:...)
| |
| 207 | {
| |
| 208 | #if defined isnull | |
| 209 | if (isnull(string)) | |
| 210 | #else | |
| 211 | if (string[0] == 0 || (string[0] == 1 && string[1] == 0)) | |
| 212 | #endif | |
| 213 | {
| |
| 214 | return format[0]; | |
| 215 | } | |
| 216 | #pragma tabsize 4 | |
| 217 | new | |
| 218 | formatPos = 0, | |
| 219 | stringPos = 0, | |
| 220 | paramPos = 2, | |
| 221 | paramCount = numargs(), | |
| 222 | delim = ' '; | |
| 223 | while (string[stringPos] && string[stringPos] <= ' ') | |
| 224 | {
| |
| 225 | stringPos++; | |
| 226 | } | |
| 227 | while (paramPos < paramCount && string[stringPos]) | |
| 228 | {
| |
| 229 | switch (format[formatPos++]) | |
| 230 | {
| |
| 231 | case '\0': | |
| 232 | {
| |
| 233 | return 0; | |
| 234 | } | |
| 235 | case 'i', 'd': | |
| 236 | {
| |
| 237 | new | |
| 238 | neg = 1, | |
| 239 | num = 0, | |
| 240 | ch = string[stringPos]; | |
| 241 | if (ch == '-') | |
| 242 | {
| |
| 243 | neg = -1; | |
| 244 | ch = string[++stringPos]; | |
| 245 | } | |
| 246 | do | |
| 247 | {
| |
| 248 | stringPos++; | |
| 249 | if ('0' <= ch <= '9')
| |
| 250 | {
| |
| 251 | num = (num * 10) + (ch - '0'); | |
| 252 | } | |
| 253 | else | |
| 254 | {
| |
| 255 | return -1; | |
| 256 | } | |
| 257 | } | |
| 258 | while ((ch = string[stringPos]) > ' ' && ch != delim); | |
| 259 | setarg(paramPos, 0, num * neg); | |
| 260 | } | |
| 261 | case 'h', 'x': | |
| 262 | {
| |
| 263 | new | |
| 264 | num = 0, | |
| 265 | ch = string[stringPos]; | |
| 266 | do | |
| 267 | {
| |
| 268 | stringPos++; | |
| 269 | switch (ch) | |
| 270 | {
| |
| 271 | case 'x', 'X': | |
| 272 | {
| |
| 273 | num = 0; | |
| 274 | continue; | |
| 275 | } | |
| 276 | case '0' .. '9': | |
| 277 | {
| |
| 278 | num = (num << 4) | (ch - '0'); | |
| 279 | } | |
| 280 | case 'a' .. 'f': | |
| 281 | {
| |
| 282 | num = (num << 4) | (ch - ('a' - 10));
| |
| 283 | } | |
| 284 | case 'A' .. 'F': | |
| 285 | {
| |
| 286 | num = (num << 4) | (ch - ('A' - 10));
| |
| 287 | } | |
| 288 | default: | |
| 289 | {
| |
| 290 | return -1; | |
| 291 | } | |
| 292 | } | |
| 293 | } | |
| 294 | while ((ch = string[stringPos]) > ' ' && ch != delim); | |
| 295 | setarg(paramPos, 0, num); | |
| 296 | } | |
| 297 | case 'c': | |
| 298 | {
| |
| 299 | setarg(paramPos, 0, string[stringPos++]); | |
| 300 | } | |
| 301 | case 'f': | |
| 302 | {
| |
| 303 | ||
| 304 | new changestr[16], changepos = 0, strpos = stringPos; | |
| 305 | while(changepos < 16 && string[strpos] && string[strpos] != delim) | |
| 306 | {
| |
| 307 | changestr[changepos++] = string[strpos++]; | |
| 308 | } | |
| 309 | changestr[changepos] = '\0'; | |
| 310 | setarg(paramPos,0,_:floatstr(changestr)); | |
| 311 | } | |
| 312 | case 'p': | |
| 313 | {
| |
| 314 | delim = format[formatPos++]; | |
| 315 | continue; | |
| 316 | } | |
| 317 | case '\'': | |
| 318 | {
| |
| 319 | new | |
| 320 | end = formatPos - 1, | |
| 321 | ch; | |
| 322 | while ((ch = format[++end]) && ch != '\'') {}
| |
| 323 | if (!ch) | |
| 324 | {
| |
| 325 | return -1; | |
| 326 | } | |
| 327 | format[end] = '\0'; | |
| 328 | if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1) | |
| 329 | {
| |
| 330 | if (format[end + 1]) | |
| 331 | {
| |
| 332 | return -1; | |
| 333 | } | |
| 334 | return 0; | |
| 335 | } | |
| 336 | format[end] = '\''; | |
| 337 | stringPos = ch + (end - formatPos); | |
| 338 | formatPos = end + 1; | |
| 339 | } | |
| 340 | case 'u': | |
| 341 | {
| |
| 342 | new | |
| 343 | end = stringPos - 1, | |
| 344 | id = 0, | |
| 345 | bool:num = true, | |
| 346 | ch; | |
| 347 | while ((ch = string[++end]) && ch != delim) | |
| 348 | {
| |
| 349 | if (num) | |
| 350 | {
| |
| 351 | if ('0' <= ch <= '9')
| |
| 352 | {
| |
| 353 | id = (id * 10) + (ch - '0'); | |
| 354 | } | |
| 355 | else | |
| 356 | {
| |
| 357 | num = false; | |
| 358 | } | |
| 359 | } | |
| 360 | } | |
| 361 | if (num && IsPlayerConnected(id)) | |
| 362 | {
| |
| 363 | setarg(paramPos, 0, id); | |
| 364 | } | |
| 365 | else | |
| 366 | {
| |
| 367 | #if !defined foreach | |
| 368 | #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2)) | |
| 369 | #define __SSCANF_FOREACH__ | |
| 370 | #endif | |
| 371 | string[end] = '\0'; | |
| 372 | num = false; | |
| 373 | new | |
| 374 | name[MAX_PLAYER_NAME]; | |
| 375 | id = end - stringPos; | |
| 376 | foreach (Player, playerid) | |
| 377 | {
| |
| 378 | GetPlayerName(playerid, name, sizeof (name)); | |
| 379 | if (!strcmp(name, string[stringPos], true, id)) | |
| 380 | {
| |
| 381 | setarg(paramPos, 0, playerid); | |
| 382 | num = true; | |
| 383 | break; | |
| 384 | } | |
| 385 | } | |
| 386 | if (!num) | |
| 387 | {
| |
| 388 | setarg(paramPos, 0, INVALID_PLAYER_ID); | |
| 389 | } | |
| 390 | string[end] = ch; | |
| 391 | #if defined __SSCANF_FOREACH__ | |
| 392 | #undef foreach | |
| 393 | #undef __SSCANF_FOREACH__ | |
| 394 | #endif | |
| 395 | } | |
| 396 | stringPos = end; | |
| 397 | } | |
| 398 | case 's', 'z': | |
| 399 | {
| |
| 400 | new | |
| 401 | i = 0, | |
| 402 | ch; | |
| 403 | if (format[formatPos]) | |
| 404 | {
| |
| 405 | while ((ch = string[stringPos++]) && ch != delim) | |
| 406 | {
| |
| 407 | setarg(paramPos, i++, ch); | |
| 408 | } | |
| 409 | if (!i) | |
| 410 | {
| |
| 411 | return -1; | |
| 412 | } | |
| 413 | } | |
| 414 | else | |
| 415 | {
| |
| 416 | while ((ch = string[stringPos++])) | |
| 417 | {
| |
| 418 | setarg(paramPos, i++, ch); | |
| 419 | } | |
| 420 | } | |
| 421 | stringPos--; | |
| 422 | setarg(paramPos, i, '\0'); | |
| 423 | } | |
| 424 | default: | |
| 425 | {
| |
| 426 | continue; | |
| 427 | } | |
| 428 | } | |
| 429 | while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ') | |
| 430 | {
| |
| 431 | stringPos++; | |
| 432 | } | |
| 433 | while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' ')) | |
| 434 | {
| |
| 435 | stringPos++; | |
| 436 | } | |
| 437 | paramPos++; | |
| 438 | } | |
| 439 | do | |
| 440 | {
| |
| 441 | if ((delim = format[formatPos++]) > ' ') | |
| 442 | {
| |
| 443 | if (delim == '\'') | |
| 444 | {
| |
| 445 | while ((delim = format[formatPos++]) && delim != '\'') {}
| |
| 446 | } | |
| 447 | else if (delim != 'z') | |
| 448 | {
| |
| 449 | return delim; | |
| 450 | } | |
| 451 | } | |
| 452 | } | |
| 453 | while (delim > ' '); | |
| 454 | return 0; | |
| 455 | } |