Advertisement
Chaoz

In Game Teleport Maker v2.0.1

Sep 22nd, 2011
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 8.01 KB | None | 0 0
  1. /*
  2. ||===========Credits============||
  3. ||The_Chaoz Scripting           ||
  4. ||Wheelmandts main idea         ||
  5. ||Y_Less y_ini, sscanf plugin   ||
  6. ||Zeex zcmd                     ||
  7. ||                              ||
  8. ||==============================||*/
  9.  
  10. #define FILTERSCRIPT
  11.  
  12. #include <a_samp>
  13. #include <YSI\y_ini>
  14. #include <sscanf2>
  15. #include <zcmd>
  16.  
  17. #define PUBLIC:%0(%1)   forward %0(%1); public %0(%1)
  18.  
  19. #define MAX_TELEPORTS   1000
  20. //#define HELP//comment this line to disable help on cmds
  21. #define PATH "/TeleportsIG.sav"
  22.  
  23. enum DD{
  24.     bool:Exist=false,
  25.     Float:PP[4],
  26.     Int,
  27.     Vw,
  28.     wCar,
  29.     Priv,
  30.     Name[11],
  31.     Owner[MAX_PLAYER_NAME],
  32.     Frace[55]
  33. };
  34.  
  35. new Tp[MAX_TELEPORTS][DD];
  36. new bool:Full = false;
  37.  
  38. public OnFilterScriptInit()
  39. {
  40.     if(!fexist("/TeleportsIG.sav")){
  41.         new File:Fhnd;
  42.         Fhnd = fopen(PATH, io_write);
  43.         if(Fhnd)fclose(Fhnd);
  44.     }
  45.     for(new i; i<MAX_TELEPORTS; i++)Tp[i][Name] = "a\0\0\0\0\0\0\0\0\0";
  46.     INI_ParseFile(PATH, "LoadTeleports", .bPassTag=true);
  47.     print("\n----------------------------------------");
  48.     print("    In Game Teleport Maker v2.0.1 Loaded");
  49.     return print("----------------------------------------\n");
  50. }
  51.  
  52. public OnFilterScriptExit()
  53. {
  54.     print("\n------------------------------------------");
  55.     print("    In Game Teleport Maker v2.0.1 Unloaded");
  56.     return print("------------------------------------------\n");
  57. }
  58.  
  59. public OnPlayerCommandReceived(playerid, cmdtext[]){
  60.     if(strcmp(cmdtext, "/tcrear", true, 6) && strcmp(cmdtext, "/tlista", true, 6) && strcmp(cmdtext, "/tborrar", true, 7))
  61.         CallLocalFunction("ExecuteTeleport", "si", cmdtext[1], playerid);
  62.     return 1;
  63. }
  64.  
  65. public OnPlayerCommandPerformed(playerid, cmdtext[], success){
  66.     new i;
  67.     for(; i<MAX_TELEPORTS; i++)if(!strcmp(Tp[i][Name], cmdtext[1], true))break;
  68.     if(Tp[i][Exist])success = 1;
  69.     return (success) ? (1) : (0);
  70. }
  71.  
  72. CMD:tcrear(playerid, params[]){
  73.     if(Full)return SendClientMessage(playerid, 0xFF0000FF, "Error: Ya no se pueden crear mas teleports.");
  74.     new name[11], Opt[2], fr[55];
  75.     if(sscanf(params, "s[11]I(0)I(0)S()[55]", name, Opt[0], Opt[1], fr)){
  76.         SendClientMessage(playerid, 0xFFFFFFFF, "Uso: /{FFFF00}tcrear {FFFF00}<nombre> {FFFFFF}(opcional){FFFF00}<auto> {FFFFFF}(opcional){FFFF00}<privado> {FFFFFF}(opcional){FFFF00}<mensaje>");
  77.         #if defined HELP
  78.             SendClientMessage(playerid, 0xFFFF00FF, "Parametros:");
  79.             SendClientMessage(playerid, 0xFFFF00FF, " #Auto: {FFFFFF}permite el teleport con o sin auto ({00FF00}1{FFFFFF}={00FF00}si{FFFFFF}/{FF0000}0{FFFFFF}={FF0000}no).");
  80.             SendClientMessage(playerid, 0xFFFF00FF, " #Privado: {FFFFFF}No figura en la lista del comando tlista({00FF00}1{FFFFFF}={00FF00}privado{FFFFFF}/{FF0000}0{FFFFFF}={FF0000}publico).");
  81.             return SendClientMessage(playerid, 0xFFFF00FF, " #Mensaje: {FFFFFF}se enviara este mensaje cada vez q alguien llegue al teleport.");
  82.         #else
  83.             return 1;
  84.         #endif
  85.     }
  86.     if(strlen(name) < 3)return SendClientMessage(playerid, 0xFF0000FF, "Error: El largo del nombre debe ser mayor a 3 caracteres.");
  87.     new i;
  88.     for(; i<MAX_TELEPORTS; i++)if(!strcmp(Tp[i][Name], name, true) && Tp[i][Exist])return SendClientMessage(playerid, 0xFF0000FF, "Error: El nombre ya ha sido utilizado.");
  89.     for(i=0; i<=MAX_TELEPORTS; i++)if(!Tp[i][Exist])break;
  90.     if(i==MAX_TELEPORTS){
  91.         Full=true;
  92.         if(Tp[i][Exist])return SendClientMessage(playerid, 0xFF0000FF, "Error: Ya no se pueden crear mas teleports.");
  93.     }
  94.     new str[66];
  95.     new INI:Fhnd;
  96.     GetPlayerPos(playerid, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
  97.     GetPlayerFacingAngle(playerid, Tp[i][PP][3]);
  98.     Tp[i][Vw] = GetPlayerVirtualWorld(playerid);
  99.     Tp[i][Int] = GetPlayerInterior(playerid);
  100.     Fhnd = INI_Open(PATH);
  101.     INI_SetTag(Fhnd, numstr(i));
  102.     INI_WriteString(Fhnd, "Name", name);
  103.     INI_WriteString(Fhnd, "Owner", pName(playerid));
  104.     INI_WriteString(Fhnd, "Frace", fr);
  105.     INI_WriteInt(Fhnd, "Car", Opt[0]);
  106.     INI_WriteInt(Fhnd, "Priv", Opt[1]);
  107.     INI_WriteFloat(Fhnd, "X", Tp[i][PP][0]);
  108.     INI_WriteFloat(Fhnd, "Y", Tp[i][PP][1]);
  109.     INI_WriteFloat(Fhnd, "Z", Tp[i][PP][2]);
  110.     INI_WriteFloat(Fhnd, "A", Tp[i][PP][3]);
  111.     INI_WriteInt(Fhnd, "vW", Tp[i][Vw]);
  112.     INI_WriteInt(Fhnd, "Int", Tp[i][Int]);
  113.     INI_Close(Fhnd);
  114.     Tp[i][Exist] = true;
  115.     Tp[i][Name] = name;
  116.     Tp[i][Owner] = pName(playerid);
  117.     Tp[i][Frace] = fr;
  118.     Tp[i][wCar] = Opt[0];
  119.     Tp[i][Priv] = Opt[1];
  120.     format(str, sizeof(str), "Has creado un nuevo teleport, usa \"/%s\" para ir a el.", name);
  121.     return SendClientMessage(playerid, 0xFFFF00FF, str);
  122. }
  123.  
  124. CMD:tlista(playerid, params[]){
  125.     #pragma unused params
  126.     new str[128], count, X;
  127.     for(new i; i<MAX_TELEPORTS; i++)if(Tp[i][Exist] && !Tp[i][Priv]){
  128.         X++;
  129.         count++;
  130.         if(count == 1)format(str, 128, "%s", Tp[i][Name]);
  131.         if(1 < count <= 5)format(str, 128, "%s - %s", str, Tp[i][Name]);
  132.         if(count == 6){
  133.             SendClientMessage(playerid, 0xFFFF00FF, str);
  134.             count = 0;
  135.         }
  136.     }
  137.     if(X && count)return SendClientMessage(playerid, 0xFFFF00FF, str);
  138.     return SendClientMessage(playerid, 0xFFFFFFFF, "--No existen teleports--");
  139. }
  140.  
  141. CMD:tborrar(playerid, params[])
  142. {
  143.     new name[11];
  144.     if(sscanf(params, "s[11]", name))return SendClientMessage(playerid, 0xFFFFFFFF, "Uso: /{FFFF00}tborrar <nombre>");
  145.     new i;
  146.     for(; i<MAX_TELEPORTS; i++)if(!strcmp(Tp[i][Name], name, true))break;
  147.     if(strcmp(Tp[i][Owner], pName(playerid), false) && !IsPlayerAdmin(playerid))return SendClientMessage(playerid, 0xFF0000FF, "Error: No puedes eliminar el teleport");
  148.     if(!Tp[i][Exist])return SendClientMessage(playerid, 0xFF0000FF, "Error: El teleport no existe.");
  149.     DeleteTp(i);
  150.     return SendClientMessage(playerid, 0x00FF00FF, "Server: Teleport borrado con exito.");
  151. }
  152.  
  153. PUBLIC:ExecuteTeleport(name[], forplayer)
  154. {
  155.     new str[128], i;
  156.     for(; i<MAX_TELEPORTS; i++)if(!strcmp(Tp[i][Name], name, true))break;
  157.     if(!Tp[i][Exist])return 0;
  158.     if(!IsPlayerInAnyVehicle(forplayer)){
  159.         SetPlayerPos(forplayer, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
  160.         SetPlayerFacingAngle(forplayer, Tp[i][PP][3]);
  161.         SetPlayerInterior(forplayer, Tp[i][Int]);
  162.         SetPlayerVirtualWorld(forplayer, Tp[i][Vw]);
  163.         SetCameraBehindPlayer(forplayer);
  164.     }
  165.     else{
  166.         if(!Tp[i][wCar]){
  167.             SetPlayerPos(forplayer, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
  168.             SetPlayerFacingAngle(forplayer, Tp[i][PP][3]);
  169.             SetPlayerInterior(forplayer, Tp[i][Int]);
  170.             SetPlayerVirtualWorld(forplayer, Tp[i][Vw]);
  171.             SetCameraBehindPlayer(forplayer);
  172.         }
  173.         else{
  174.             new Veh = GetPlayerVehicleID(forplayer);
  175.             SetVehiclePos(Veh, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
  176.             SetVehicleZAngle(Veh, Tp[i][PP][3]);
  177.             PutPlayerInVehicle(forplayer, Veh, 0);
  178.             SetVehicleVirtualWorld(Veh, Tp[i][Vw]);
  179.             LinkVehicleToInterior(Veh, Tp[i][Int]);
  180.             SetCameraBehindPlayer(forplayer);
  181.         }
  182.     }
  183.     if(!strlen(Tp[i][Frace]))format(str, 128, "Has ido a \"%s\" creado por %s.", Tp[i][Name], Tp[i][Owner]);
  184.     else format(str, 128, "\"%s\" por %s.", Tp[i][Frace], Tp[i][Owner]);
  185.     SendClientMessage(forplayer, 0xFFFF00FF, str);
  186.     return 1;
  187. }
  188.  
  189. PUBLIC:LoadTeleports(tag[], name[], value[])
  190. {
  191.     new ID=strval(tag);
  192.     Tp[ID][Exist] = true;
  193.     if(!strcmp(name, "Name", true))format(Tp[ID][Name], 11, "%s", value);
  194.     if(!strcmp(name, "Owner", true))format(Tp[ID][Owner], MAX_PLAYER_NAME, "%s", value);
  195.     if(!strcmp(name, "Car", true))Tp[ID][wCar] = strval(value);
  196.     if(!strcmp(name, "Priv", true))Tp[ID][Priv] = strval(value);
  197.     if(!strcmp(name, "X", true))Tp[ID][PP][0] = floatstr(value);
  198.     if(!strcmp(name, "Y", true))Tp[ID][PP][1] = floatstr(value);
  199.     if(!strcmp(name, "Z", true))Tp[ID][PP][2] = floatstr(value);
  200.     if(!strcmp(name, "A", true))Tp[ID][PP][3] = floatstr(value);
  201.     if(!strcmp(name, "Vw", true))Tp[ID][Vw] = strval(value);
  202.     if(!strcmp(name, "Int", true))Tp[ID][Int] = strval(value);
  203.     if(ID==MAX_TELEPORTS)Full = true;
  204. }
  205.  
  206. pName(playerid)
  207. {
  208.     new name[MAX_PLAYER_NAME] = "INVALID PLAYER";
  209.     if(!IsPlayerConnected(playerid))return name;
  210.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  211.     return name;
  212. }
  213.  
  214. DeleteTp(T_id)
  215. {
  216.     Tp[T_id][Exist] = false;
  217.     new INI:Fhnd;
  218.     Fhnd = INI_Open(PATH);
  219.     INI_DeleteTag(Fhnd, numstr(T_id));
  220.     INI_Close(Fhnd);
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement