Advertisement
Chaoz

In Game Teleport Maker v1.2

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