Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.88 KB | None | 0 0
  1. #include <a_samp>
  2. new Float:xg, Float:yg, Float:zg;
  3. new goid;
  4. new nega[MAX_PLAYERS];
  5. new fname[MAX_PLAYER_NAME];
  6. new gname[MAX_PLAYER_NAME];
  7. new fromid;
  8. #define GREEN 0x33AA33AA
  9. #define RED 0xAA3333AA
  10.  
  11. public OnFilterScriptInit()
  12. {
  13.         print("\n--------------------------------------");
  14.         print(" Teleport System by Profondo");
  15.         print("--------------------------------------\n");
  16.         return 1;
  17. }
  18.  
  19. public OnFilterScriptExit()
  20. {
  21.         return 1;
  22. }
  23.  
  24.  
  25.  
  26. public OnPlayerConnect(playerid)
  27. {
  28.         nega[playerid] = 0;
  29.         return 1;
  30. }
  31.  
  32. public OnPlayerDisconnect(playerid, reason)
  33. {
  34.  nega[playerid] = 0;
  35.  return 1;
  36. }
  37.  
  38.  
  39.  
  40. public OnPlayerCommandText(playerid, cmdtext[])
  41. {
  42.         new cmd[256], idx;
  43.         cmd = strtok(cmdtext, idx);
  44.         new string[256];
  45.  
  46.         if (strcmp("/deney", cmdtext, true, 10) == 0)
  47.         {
  48.         if(nega[playerid] == 0) {
  49.         nega[playerid] = 1;
  50.         SendClientMessage(playerid, GREEN, "Tutte le richieste saranno automaticamente respinte");
  51.         SendClientMessage(playerid, RED, "Eseguire nuovamente il comando per disattivare questa opzione");
  52.         } else {
  53.         nega[playerid] = 0;
  54.         SendClientMessage(playerid, GREEN, "Possibilità di teletrasporto attivato");
  55.         }
  56.         return 1;
  57.         }
  58.  
  59.         if (strcmp(cmd, "/go", true, 10) == 0)
  60.         {
  61.         new tmp[256];
  62.         new stringdomanda[256];
  63.         tmp = strtok(cmdtext, idx);
  64.         goid = strval(tmp);
  65.         playerid = fromid;
  66.         GetPlayerName(goid, gname, sizeof(gname));
  67.         GetPlayerName(fromid, fname, sizeof(fname));
  68.  
  69.  
  70.         if(strlen(tmp) == 0) SendClientMessage(playerid, RED, "USO: /vai [PLAYERID]");
  71.  
  72.         else if (!IsNumeric2(tmp)) SendClientMessage(playerid, RED, "ID NON VALIDO");
  73.  
  74.         else if(goid == INVALID_PLAYER_ID) SendClientMessage(playerid, RED, "ID NON VALIDO");
  75.  
  76.         else
  77.         {
  78.  
  79.         if(nega[goid] != 1) {
  80.  
  81.         format(string, sizeof(string), "Richiesta di teletrasporto inviata %s", gname);
  82.         SendClientMessage(fromid, GREEN, string);
  83.  
  84.         format(stringdomanda, sizeof(stringdomanda), " %s ha richiesto di teleportarsi da te accetti?", fname);
  85.         ShowPlayerDialog(goid,48,0,"Tele",stringdomanda,"Si","No");
  86.  
  87.         } else {
  88.         format(string, sizeof(string), "%s Ha Rifiutato La Richiesta", gname);
  89.         SendClientMessage(fromid, GREEN, string);
  90.         }
  91.         }
  92.  
  93.         return 1;
  94.         }
  95.         return 0;
  96. }
  97.  
  98.  
  99.  
  100. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  101. {
  102.  
  103.         if(dialogid == 48)
  104.  {
  105.         if(response == 1){
  106.         GetPlayerPos(goid, xg, yg, zg);
  107.         SetPlayerPos(fromid, xg, yg, zg);
  108.         } else {
  109.         new string[256];
  110.         format(string, sizeof(string), "%s Ha rifiutato la richiesta", gname);
  111.         SendClientMessage(fromid, RED, string);
  112.         }
  113.         }
  114.  
  115.         return 1;
  116. }
  117.  
  118. strtok(const string[], &index)
  119. {
  120.         new length = strlen(string);
  121.         while ((index < length) && (string[index] <= ' '))
  122.         {
  123.         index++;
  124.         }
  125.  
  126.         new offset = index;
  127.         new result[20];
  128.         while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  129.         {
  130.         result[index - offset] = string[index];
  131.         index++;
  132.         }
  133.         result[index - offset] = EOS;
  134.         return result;
  135. }
  136.  
  137. IsNumeric2(const string[])
  138. {
  139.  
  140.         new length=strlen(string);
  141.         if (length==0) return false;
  142.         for (new i = 0; i < length; i++)
  143.         {
  144.         if((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+' && string[i]!='.')
  145.         || (string[i]=='-' && i!=0)
  146.         || (string[i]=='+' && i!=0)
  147.         ) return false;
  148.         }
  149.         if (length==1 && (string[0]=='-' || string[0]=='+' || string[0]=='.')) return false;
  150.         return true;
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement