Advertisement
Guest User

treasure hunt

a guest
Nov 22nd, 2021
1,025
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.32 KB | None | 0 0
  1. #include <a_samp>
  2. #include <YSI\y_va>
  3. #include <YSI\y_groups>
  4. #include <Pawn.CMD>
  5. #include <sscanf2>
  6.  
  7. new nagrada,Float:xPos[3],xPickup,bool:xpokrenut,Group:ghunt;
  8. public OnFilterScriptInit()
  9. {
  10.     print("\n--------------------------------------");
  11.     print(" Treasuer Hunt by Common uspjesno ucitan");
  12.     print("--------------------------------------\n");
  13.     ghunt = Group_Create("trhunt");
  14.     return 1;
  15. }
  16. public OnPlayerDisconnect(playerid, reason)
  17. {
  18.     if(xpokrenut && GetPVarInt(playerid, "IsJoined") != 0) { DeletePVar(playerid, "IsJoined"); Group_SetPlayer(ghunt, playerid, false); }
  19.     return 1;
  20. }
  21. public OnPlayerEnterCheckpoint(playerid)
  22. {
  23.     if(xpokrenut && GetPVarInt(playerid, "IsJoined") != 0 && IsPlayerInRangeOfPoint(playerid,1.5,xPos[0],xPos[1],xPos[2]))
  24.     {
  25.         DeletePVar(playerid, "IsJoined"); xpokrenut = false; DestroyPickup(xPickup);
  26.         GivePlayerMoney(playerid,nagrada); DisablePlayerCheckpoint(playerid);
  27.         va_SendClientMessageToAll(-1,"{FCB514}[HUNT] {ffffff}%s je pronasao torbu sa %d$.",GetName(playerid),nagrada); nagrada = 0;
  28.         //ovo dole sam morao ovako napraviti jer se skripta rusi kada izbacujes direktno iz grupe dok traje foreach
  29.         new ide[MAX_PLAYERS],brojka;
  30.         foreach(Group(ghunt), id) { ide[brojka] = id; brojka ++; }
  31.         for(new i; i < brojka; i++)
  32.         {
  33.             Group_SetPlayer(ghunt, ide[i], false); DeletePVar(ide[i], "IsJoined"); DisablePlayerCheckpoint(playerid);
  34.         }
  35.     }
  36.     return 1;
  37. }
  38. CMD:ah(playerid, params[])
  39. {
  40.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1, "Nisi ovlasten!");
  41.     SendClientMessage(playerid,-1,"/thunt /ao");
  42.     return 1;
  43. }
  44. CMD:ao(playerid, params[])
  45. {
  46.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1, "Nisi ovlasten!");
  47.     new string[40];
  48.     if(sscanf(params,"s[40]",string)) return SendClientMessage(playerid,-1,"/ao [poruka]");
  49.     va_SendClientMessageToAll(-1," [A] Admin %s: %s.",GetName(playerid),string);
  50.     return 1;
  51. }
  52. CMD:thunt(playerid, params[])
  53. {
  54.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1, "Nisi ovlasten!");
  55.     if(xpokrenut) return SendClientMessage(playerid,-1,"Event je vec pokrenut");
  56.     if(sscanf(params,"d",nagrada)) return SendClientMessage(playerid,-1,"/thunt [nagrada]");
  57.     va_SendClientMessageToAll(-1,"Pokrenut je treasure hunt sa nagradom %d$. Da se prikljucite /join.",nagrada);
  58.     GetPlayerPos(playerid,xPos[0],xPos[1],xPos[2]); xpokrenut = true;
  59.     xPickup = CreatePickup(1210, 1, xPos[0],xPos[1],xPos[2]);
  60.     return 1;
  61. }
  62. CMD:join(playerid, params[])
  63. {
  64.     if(GetPVarInt(playerid, "IsJoined") == 1 || !xpokrenut) return SendClientMessage(playerid,-1,"Vec ucestvujes ili event nije pokrenut");
  65.     SetPVarInt(playerid, "IsJoined", 1); SendClientMessage(playerid,-1,"Uspjesno si se prikljucio {FCB514}Treasure Huntu");
  66.     SetPlayerCheckpoint(playerid,xPos[0],xPos[1],xPos[2],1.5); Group_SetPlayer(ghunt, playerid, true);
  67.     return 1;
  68. }
  69. CMD:left(playerid, params[])
  70. {
  71.     if(!xpokrenut || GetPVarInt(playerid, "IsJoined") == 0) return SendClientMessage(playerid,-1,"Ne ucestvujes u potrazi ili event nije pokrenut");
  72.     DeletePVar(playerid, "IsJoined"); SendClientMessage(playerid,-1,"Uspjesno si leftao {FCB514}Treasure Hunt");
  73.     DisablePlayerCheckpoint(playerid); Group_SetPlayer(ghunt, playerid, false);
  74.     return 1;
  75. }
  76. GetName(id)
  77. {
  78.     new name[MAX_PLAYER_NAME + 1];
  79.     GetPlayerName(id, name, sizeof(name));
  80.     return name;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement