Advertisement
Chaoz

In Game Teleport Maker v1.1

Apr 29th, 2011
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.49 KB | None | 0 0
  1. /*||===========Creditos===========||
  2.   ||                              ||
  3.   ||     Scripter: CH4øZ          ||
  4.   ||     Idea: Wheelmandts        ||
  5.   ||                              ||
  6.   ||   [email protected]    ||
  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.1.0 Loaded");
  49.     return print("--------------------------------------\n");
  50. }
  51.  
  52. public OnFilterScriptExit()
  53. {
  54.     print("\n--------------------------------------");
  55.     print("    In Game Teleport Maker v1.1.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.     return 0;
  65. }
  66.  
  67. dcmd_tcrear(playerid, params[]){
  68.     if(Full)return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Ya no se pueden crear mas teleports.");
  69.     new name[11], Opt[2], fr[55];
  70.     if(sscanf(params, "s[11]D(0)D(0)S()[55]", name, Opt[0], Opt[1], fr)){
  71.         SendClientMessage(playerid, 0xFFFFFFFF, "Uso: /{FFFF00}tcrear {FFFF00}<nombre> {FFFFFF}(opcional){FFFF00}<auto> {FFFFFF}(opcional){FFFF00}<privado> {FFFFFF}(opcional){FFFF00}<mensaje>");
  72.         #if defined HELP
  73.             SendClientMessage(playerid, 0xFFFF00FF, "Parametros:");
  74.             SendClientMessage(playerid, 0xFFFF00FF, " #Auto: {FFFFFF}permite el teleport con o sin auto ({00FF00}1{FFFFFF}={00FF00}si{FFFFFF}/{FF0000}0{FFFFFF}={FF0000}no).");
  75.             SendClientMessage(playerid, 0xFFFF00FF, " #Privado: {FFFFFF}No figura en la lista del comando tlista({00FF00}1{FFFFFF}={00FF00}privado{FFFFFF}/{FF0000}0{FFFFFF}={FF0000}publico).");
  76.             return SendClientMessage(playerid, 0xFFFF00FF, " #Mensaje: {FFFFFF}se enviara este mensaje cada vez q alguien llegue al teleport.");
  77.         #else
  78.             return 1;
  79.         #endif
  80.     }
  81.     if(strlen(name) < 3)return SendClientMessage(playerid, 0xFF0000FF, "Error: El largo del nombre debe ser mayor a 3 caracteres.");
  82.     for(new l; l<MAX_TELEPORTS; l++){
  83.         if(!strcmp(Tp[l][Name], name, true) && Tp[l][Exist])return SendClientMessage(playerid, 0xFF0000FF, "ERROR: El nombre ya ha sido utilizado.");
  84.         else continue;
  85.     }
  86.     new i;
  87.     for(i=0; i<=MAX_TELEPORTS; i++)if(!Tp[i][Exist])break;
  88.     if(i==MAX_TELEPORTS){
  89.         Full=true;
  90.         if(Tp[i][Exist])return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Ya no se pueden crear mas teleports.");
  91.     }
  92.     new str[66];
  93.     new INI:Fhnd;
  94.     GetPlayerPos(playerid, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
  95.     GetPlayerFacingAngle(playerid, Tp[i][PP][3]);
  96.     Tp[i][Vw] = GetPlayerVirtualWorld(playerid);
  97.     Tp[i][Int] = GetPlayerInterior(playerid);
  98.     Fhnd = INI_Open(PATH);
  99.     INI_SetTag(Fhnd, numstr(i));
  100.     INI_WriteString(Fhnd, "Name", name);
  101.     INI_WriteString(Fhnd, "Owner", pName(playerid));
  102.     INI_WriteString(Fhnd, "Frace", fr);
  103.     INI_WriteInt(Fhnd, "Car", Opt[0]);
  104.     INI_WriteInt(Fhnd, "Priv", Opt[1]);
  105.     INI_WriteFloat(Fhnd, "X", Tp[i][PP][0]);
  106.     INI_WriteFloat(Fhnd, "Y", Tp[i][PP][1]);
  107.     INI_WriteFloat(Fhnd, "Z", Tp[i][PP][2]);
  108.     INI_WriteFloat(Fhnd, "A", Tp[i][PP][3]);
  109.     INI_WriteInt(Fhnd, "vW", Tp[i][Vw]);
  110.     INI_WriteInt(Fhnd, "Int", Tp[i][Int]);
  111.     INI_Close(Fhnd);
  112.     Tp[i][Exist] = true;
  113.     Tp[i][Name] = name;
  114.     Tp[i][Owner] = pName(playerid);
  115.     Tp[i][Frace] = fr;
  116.     Tp[i][wCar] = Opt[0];
  117.     Tp[i][Priv] = Opt[1];
  118.     format(str, sizeof(str), "Has creado un nuevo teleport, usa /ir \"%s\" para ir a el.", name);
  119.     return SendClientMessage(playerid, 0xFFFF00FF, str);
  120. }
  121.  
  122. dcmd_tir(playerid, params[]){
  123.     if(!params[0] || strlen(params)>11)return SendClientMessage(playerid, 0xFFFFFFFF, "Uso: /{FFFF00}tir <nombre>");
  124.     new str[128], i;
  125.     for(i=0; i<MAX_TELEPORTS; i++)if(!strcmp(Tp[i][Name], params, true))break;
  126.     if(!Tp[i][Exist])return SendClientMessage(playerid, 0xFF0000FF, "ERROR: El teleport no existe.");
  127.     if(!IsPlayerInAnyVehicle(playerid)){
  128.         SetPlayerPos(playerid, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
  129.         SetPlayerFacingAngle(playerid, Tp[i][PP][3]);
  130.         SetPlayerInterior(playerid, Tp[i][Int]);
  131.         SetPlayerVirtualWorld(playerid, Tp[i][Vw]);
  132.         SetCameraBehindPlayer(playerid);
  133.     }
  134.     else{
  135.         if(!Tp[i][wCar]){
  136.             SetPlayerPos(playerid, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
  137.             SetPlayerFacingAngle(playerid, Tp[i][PP][3]);
  138.             SetPlayerInterior(playerid, Tp[i][Int]);
  139.             SetPlayerVirtualWorld(playerid, Tp[i][Vw]);
  140.             SetCameraBehindPlayer(playerid);
  141.         }
  142.         else{
  143.             new Veh = GetPlayerVehicleID(playerid);
  144.             SetVehiclePos(Veh, Tp[i][PP][0], Tp[i][PP][1], Tp[i][PP][2]);
  145.             SetVehicleZAngle(Veh, Tp[i][PP][3]);
  146.             PutPlayerInVehicle(playerid, Veh, 0);
  147.             SetVehicleVirtualWorld(Veh, Tp[i][Vw]);
  148.             LinkVehicleToInterior(Veh, Tp[i][Int]);
  149.             SetCameraBehindPlayer(playerid);
  150.         }
  151.     }
  152.     if(!strlen(Tp[i][Frace]))format(str, 128, "Has ido a \"%s\" creado por %s.", Tp[i][Name], Tp[i][Owner]);
  153.     if(strlen(Tp[i][Frace])>1)format(str, 128, "\"%s\" por %s.", Tp[i][Frace], Tp[i][Owner]);
  154.     return SendClientMessage(playerid, 0xFFFF00FF, str);
  155. }
  156.  
  157. dcmd_tlista(playerid, params[]){
  158.     #pragma unused params
  159.     new str[128], count, X;
  160.     for(new i; i<MAX_TELEPORTS; i++)if(Tp[i][Exist] && !Tp[i][Priv]){
  161.         X++;
  162.         count++;
  163.         if(count == 1)format(str, 128, "%s", Tp[i][Name]);
  164.         if(1 < count <= 5)format(str, 128, "%s - %s", str, Tp[i][Name]);
  165.         if(count == 6){
  166.             SendClientMessage(playerid, 0xFFFF00FF, str);
  167.             count = 0;
  168.         }
  169.     }
  170.     if(X && count)return SendClientMessage(playerid, 0xFFFF00FF, str);
  171.     return SendClientMessage(playerid, 0xFFFFFFFF, "--No existen teleports--");
  172. }
  173.  
  174. forward LoadTeleports(tag[], name[], value[]);
  175. public LoadTeleports(tag[], name[], value[])
  176. {
  177.     new ID=strval(tag);
  178.     Tp[ID][Exist] = true;
  179.     if(!strcmp(name, "Name", true))format(Tp[ID][Name], 11, "%s", value);
  180.     if(!strcmp(name, "Owner", true))format(Tp[ID][Owner], MAX_PLAYER_NAME, "%s", value);
  181.     if(!strcmp(name, "Car", true))Tp[ID][wCar] = strval(value);
  182.     if(!strcmp(name, "Priv", true))Tp[ID][Priv] = strval(value);
  183.     if(!strcmp(name, "X", true))Tp[ID][PP][0] = floatstr(value);
  184.     if(!strcmp(name, "Y", true))Tp[ID][PP][1] = floatstr(value);
  185.     if(!strcmp(name, "Z", true))Tp[ID][PP][2] = floatstr(value);
  186.     if(!strcmp(name, "A", true))Tp[ID][PP][3] = floatstr(value);
  187.     if(!strcmp(name, "Vw", true))Tp[ID][Vw] = strval(value);
  188.     if(!strcmp(name, "Int", true))Tp[ID][Int] = strval(value);
  189.     if(ID==MAX_TELEPORTS)Full = true;
  190. }
  191.  
  192. stock pName(playerid)
  193. {
  194.     new name[MAX_PLAYER_NAME] = "INVALID PLAYER";
  195.     if(!IsPlayerConnected(playerid))return name;
  196.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  197.     return name;
  198. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement