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