Guest User

House System Problem

a guest
Mar 15th, 2012
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 28.18 KB | None | 0 0
  1. // This is a comment
  2. // uncomment the line below if you want to write a filterscript
  3. //#define FILTERSCRIPT
  4. //INCLUDED
  5. #include <a_samp>
  6. #include <a_zones>
  7. #include <streamer>
  8. #include <SII>
  9. #include <zcmd>
  10. #include <dutils>
  11. #include <Dini>
  12. #include <foreach>
  13. #include <progress>
  14. #include <YSI\y_timers>
  15. #include <sscanf2>
  16.  
  17. //Defined
  18. #define COLOR_YELLOW 0xFFFF00FF
  19. #define COLOR_SYSTEM 0xFFFF00FF
  20. #define COLOR_PURPLE 0xC2A2DAAA
  21. #define COLOR_WHITE 0xFFFFFFAA
  22. #define COLOR_RED 0x660000AA
  23. #define COLOR_PINK 0xFF66FFAA
  24. #define COLOR_LIGHTBLUE 0x33CCFFAA
  25. #define COLOR_DARKRED 0x660000AA
  26. #define COLOR_GREY 0xAFAFAFAA
  27. #define COLOR_ERRO 0xD2691EAA
  28. #define COLOR_ORANGE 0xFF9900AA
  29. #define COLOR_NICEPINK 0xEC13COFF
  30. #define COLOR_GRAD1 0xB4B5B7AA
  31. #define TEAM_AZTECAS_COLOR 0x01FCFFC8
  32. #define COLOR_LIGHTGREEN 0x7CFC00AA
  33.  
  34. #define MAX_PING 500
  35. #define MAX_HOUSES 200
  36.  
  37. #define SERVER_USER_FILE "users/%s.ini"
  38.  
  39. #define IPI INVALID_PLAYER_ID
  40. #define SCM SendClientMessage
  41. #define SCMTA SendClientMessageToAll
  42. #define Register 0
  43. #define Logged 1
  44.  
  45.  
  46. //Pragma
  47. #pragma unused ret_memcpy
  48. #pragma tabsize 0
  49.  
  50. enum hInfo
  51. {
  52.     Float:hEnterX, //Entrance X. It's an float! example: 0.0000000. I'm gonna use the same with the other entrances/exits
  53.     Float:hEnterY,
  54.     Float:hEnterZ,
  55.     Float:hExitX,
  56.     Float:hExitY,
  57.     Float:hExitZ,
  58.     InsideInt, //The inside interior.. DUH!
  59.     InsideVir, //Already subscribed above
  60.     OutsideInt,
  61.     OutsideVir,
  62.     bool:hOwned, //boolean! Is house owned? NO = False, YES = True
  63.     hOwner[MAX_PLAYER_NAME], //The house owner! I'm gonna use MAX_PLAYER_NAME, because a player can't have a longer name :')
  64.     hPrice, //Will store the price
  65.     hPickup, //The pickup. This is used to remove/move the pickup icon!
  66.     hIcon, //The map icon. Also used to remove/move it! We are going to need an ID. Without an ID we can't do NOTHING!
  67.     hVecModel, //The housecar's model
  68.     hOutsideInt,
  69.     hOutsideVir,
  70.     hInsideInt,
  71.     hInsideVir,
  72.     Float:hVecX, //X location. En float too.
  73.     Float:hVecY,
  74.     Float:hVecZ,
  75.     Float:hVecA
  76. };
  77.  
  78. enum Info
  79. {
  80.     pPassword[128],
  81.     pLevel,
  82.     pExp,
  83.     pCash,
  84.     pAccent,
  85.     pAdminLevel,
  86.     pAdmin,
  87.     pHelper,
  88.     pw,
  89.     AdminLevel,
  90.     cash,
  91.     level
  92. };
  93.  
  94. new PlayerInfo[MAX_PLAYERS][Info];
  95. new Login[MAX_PLAYERS];
  96. new gPlayerLogged[MAX_PLAYERS];
  97. new HouseInfo[MAX_PLAYERS][hInfo];
  98. new HouseCar[MAX_PLAYERS];
  99. new fstring[10];
  100. forward OnPlayerLogin(playerid,const string[]);
  101. forward String(string[]);
  102. forward ScoreUpdate();
  103. forward PayDay(playerid);
  104. forward PlayerPlayMusic(playerid);
  105. forward StopMusic();
  106. new pClass[MAX_PLAYERS];
  107.  
  108.  
  109. #if defined FILTERSCRIPT
  110.  
  111. public OnFilterScriptInit()
  112. {
  113.     print("\n--------------------------------------");
  114.     print(" FeRRum");
  115.     print("--------------------------------------\n");
  116.     return 1;
  117. }
  118.  
  119. public OnFilterScriptExit()
  120. {
  121.     return 1;
  122. }
  123.  
  124. #else
  125.  
  126. main()
  127. {
  128.     print("\n----------------------------------");
  129.     print(" FeRRum");
  130.     print("----------------------------------\n");
  131. }
  132.  
  133. #endif
  134.  
  135. public OnGameModeInit()
  136. {
  137.     // Don't use these lines if it's a filterscript
  138.     SetTimer("UpdatePlayersHouseInfo", 1000, true);
  139.     SetGameModeText("C:RP 0.0.1");
  140.     UsePlayerPedAnims();
  141.     AddPlayerClass(299,2412.2659,90.9850,26.4721,90.9184,0,0,0,0,0,0); // Country
  142.     return 1;
  143. }
  144.  
  145. public OnGameModeExit()
  146. {
  147.     return 1;
  148. }
  149.  
  150. public OnPlayerRequestClass(playerid, classid)
  151. {
  152.  
  153.     pClass[playerid] = classid;
  154.     SetPlayerPos(playerid, 2412.2659, 90.9850, 26.4721);
  155.     SetPlayerCameraPos(playerid, 2412.2659, 90.9850, 26.4721);
  156.     SetPlayerCameraLookAt(playerid, 2412.2659, 90.9850, 26.4721);
  157.     TogglePlayerSpectating(playerid, 0);
  158.     return 1;
  159. }
  160.  
  161. public OnPlayerConnect(playerid)
  162. {
  163.     SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Country Roleplay version 0.0.1");
  164.     PlayerInfo[playerid][pLevel] = 1;
  165.     PlayerInfo[playerid][pExp] = 0;
  166.  
  167.     Login[playerid] = 0;
  168.     new nombre[MAX_PLAYER_NAME], archivo[256];
  169.     GetPlayerName(playerid, nombre, sizeof(nombre));
  170.     format(archivo, sizeof(archivo), "/Users/%s.ini", nombre);
  171.     if (!dini_Exists(archivo))
  172.         {
  173.         ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Register", "He writes your password:", "Acept", "Cancel");
  174.         }
  175.     else
  176.     {
  177.         ShowPlayerDialog(playerid, Logged, DIALOG_STYLE_INPUT, "Login", "He writes your password", "Acept", "Cancel");
  178.     }
  179.     return 1;
  180. }
  181.  
  182. public OnPlayerDisconnect(playerid, reason)
  183. {
  184.     return 1;
  185. }
  186.  
  187. public OnPlayerSpawn(playerid)
  188. {
  189.     SetPlayerPos(playerid, 2412.2659,90.9850,26.4721);
  190.     switch(pClass[playerid])
  191.     {
  192.         case 0:
  193.         {
  194.             // If the player's class is 0 then set it to White
  195.             SetPlayerColor(playerid, 0xFFFFFFAA); // White
  196.         }
  197.     }
  198.     return 1;
  199. }
  200.  
  201. public OnPlayerDeath(playerid, killerid, reason)
  202. {
  203.     return 1;
  204. }
  205.  
  206. public OnVehicleSpawn(vehicleid)
  207. {
  208.     return 1;
  209. }
  210.  
  211. public OnVehicleDeath(vehicleid, killerid)
  212. {
  213.     return 1;
  214. }
  215.  
  216. public OnPlayerText(playerid, text[])
  217. {
  218.     return 1;
  219. }
  220.  
  221. public OnPlayerCommandText(playerid, cmdtext[])
  222. {
  223. if(!strcmp(cmdtext, "/buyhouse", true))
  224. {
  225.     new pName[MAX_PLAYER_NAME]; //For the player's name - For the house
  226.     GetPlayerName(playerid, pName, MAX_PLAYER_NAME); //Get the name of the player and store it in [u]pName[/u]
  227.     for(new i = 0; i < MAX_HOUSES; i++) //Last time I'm gonna say it: Loop through all the houses
  228.     {
  229.         if(IsPlayerInRangeOfPoint(playerid, 1.5, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == HouseInfo[i][hOutsideInt] && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hOutsideVir]) //Is player near house entrance, and if player is in interior of that house + virtual world (Last time I said this too!)
  230.         {
  231.             if(HouseInfo[i][hOwned]) return SendClientMessage(playerid, COLOR_RED, "This house is already owned!"); //Is the house owned? Then send message that it's owned and stop.
  232.             if(GetPlayerMoney(playerid) < HouseInfo[i][hPrice]) return SendClientMessage(playerid, COLOR_RED, "You don't have enough money for this!"); //Has player too less money? Send him a message!
  233.  
  234.             HouseInfo[i][hOwned] = true; //The house is owned, where the player used /buyhouse
  235.             strmid(HouseInfo[i][hOwner], pName, 0, false, strlen(pName)); //Put the players name into the "hOwner" of the house
  236.             GivePlayerMoney(playerid, -HouseInfo[i][hPrice]); //Remove some money of the player.. The value of the house
  237.             SendClientMessage(playerid, COLOR_LIGHTGREEN, "House bought!"); //Send the player an message.
  238.             SaveHouse(i);
  239.             LoadHouseVisual(i, true); //Load House Visual. Now, I've added ', true': It will RELOAD now!
  240.             return 1;
  241.         }
  242.     }
  243.     return 1;
  244. }
  245. if(!strcmp(cmdtext, "/sellhouse", true))
  246. {
  247.     new pName[MAX_PLAYER_NAME]; //See /buyhouse
  248.     GetPlayerName(playerid, pName, MAX_PLAYER_NAME); //See new pName[MAX_PLAYER_NAME];
  249.     for(new i = 0; i < MAX_HOUSES; i++)
  250.     {
  251.         if(IsPlayerInRangeOfPoint(playerid, 1.5, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == HouseInfo[i][hOutsideInt] && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hOutsideVir])
  252.         {
  253.             if(!strcmp(HouseInfo[i][hOwner], pName, false)) //Is the owner of the house the same as the players name (is the player the owner?? !)
  254.             {
  255.                 strmid(HouseInfo[i][hOwner], "For Sale", 0, false, 8); //Set the owner of the house to "For Sale"
  256.                 HouseInfo[i][hOwned] = false; //House is not owner anymore!
  257.                 GivePlayerMoney(playerid, HouseInfo[i][hPrice]/2); //Give the player 50% of the house value back!
  258.                 SendClientMessage(playerid, COLOR_LIGHTGREEN, "House sold!");
  259.                 SaveHouse(i);
  260.                 LoadHouseVisual(i, true); //Load House Visual. Now, I've added ', true': It will RELOAD now!
  261.                 return 1;
  262.             }
  263.          }
  264.     }
  265.     return 1;
  266. }
  267.     return 1;
  268. }
  269. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  270. {
  271.     return 1;
  272. }
  273.  
  274. public OnPlayerExitVehicle(playerid, vehicleid)
  275. {
  276.     return 1;
  277. }
  278.  
  279. public OnPlayerStateChange(playerid, newstate, oldstate)
  280. {
  281.     return 1;
  282. }
  283.  
  284. public OnPlayerEnterCheckpoint(playerid)
  285. {
  286.     return 1;
  287. }
  288.  
  289. public OnPlayerLeaveCheckpoint(playerid)
  290. {
  291.     return 1;
  292. }
  293.  
  294. public OnPlayerEnterRaceCheckpoint(playerid)
  295. {
  296.     return 1;
  297. }
  298.  
  299. public OnPlayerLeaveRaceCheckpoint(playerid)
  300. {
  301.     return 1;
  302. }
  303.  
  304. public OnRconCommand(cmd[])
  305. {
  306.     return 1;
  307. }
  308.  
  309. public OnPlayerRequestSpawn(playerid)
  310. {
  311.     return 1;
  312. }
  313.  
  314. public OnObjectMoved(objectid)
  315. {
  316.     return 1;
  317. }
  318.  
  319. public OnPlayerObjectMoved(playerid, objectid)
  320. {
  321.     return 1;
  322. }
  323.  
  324. public OnPlayerPickUpPickup(playerid, pickupid)
  325. {
  326.     return 1;
  327. }
  328.  
  329. public OnVehicleMod(playerid, vehicleid, componentid)
  330. {
  331.     return 1;
  332. }
  333.  
  334. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  335. {
  336.     return 1;
  337. }
  338.  
  339. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  340. {
  341.     return 1;
  342. }
  343.  
  344. public OnPlayerSelectedMenuRow(playerid, row)
  345. {
  346.     return 1;
  347. }
  348.  
  349. public OnPlayerExitedMenu(playerid)
  350. {
  351.     return 1;
  352. }
  353.  
  354. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  355. {
  356.     return 1;
  357. }
  358.  
  359. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  360. {
  361. if(newkeys & 16 && !IsPlayerInAnyVehicle(playerid)) //If player pressed ENTER_VEHICLe and if he's not in an vehicle
  362.     {
  363.         for(new i = 0; i < MAX_HOUSES; i++) //Loop through all the houses
  364.         {
  365.             if(IsPlayerInRangeOfPoint(playerid, 1.5, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]) && GetPlayerInterior(playerid) == HouseInfo[i][hOutsideInt] && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hOutsideVir]) //Is player near house entrance, and if player is in interior of that house + virtual world
  366.             {
  367.                 SetPlayerPos(playerid, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]);
  368.                 SetPlayerInterior(playerid, HouseInfo[i][hInsideInt]);
  369.                 SetPlayerVirtualWorld(playerid, HouseInfo[i][hInsideVir]);
  370.                 //This will put the player IN the house
  371.             }
  372.             else if(IsPlayerInRangeOfPoint(playerid, 1.5, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]) && GetPlayerInterior(playerid) == HouseInfo[i][hInsideInt] && GetPlayerVirtualWorld(playerid) == HouseInfo[i][hInsideVir]) //Same as the previous IsPlayerInRangeOfPoint, but now if the player is near the house exit+int+vir
  373.             {
  374.                 SetPlayerPos(playerid, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]);
  375.                 SetPlayerInterior(playerid, HouseInfo[i][hOutsideInt]);
  376.                 SetPlayerVirtualWorld(playerid, HouseInfo[i][hOutsideVir]);
  377.             }
  378.         }
  379.     }
  380.     return 1;
  381. }
  382. public OnRconLoginAttempt(ip[], password[], success)
  383. {
  384.     return 1;
  385. }
  386.  
  387. public OnPlayerLogin(playerid,const string[])
  388. {
  389.     return 1;
  390. }
  391. stock LoadHouse(houseid)
  392. {
  393.     new fstring[10]; //The string for the file [format]
  394.     format(fstring, 10, "Houses/%d", houseid); //Format the filename
  395.     if(!dini_Exists(fstring)) return 0; //"If Houses/{houseid} not exists then return False (0)"
  396.     {
  397.         HouseInfo[houseid][hEnterX] = dini_Float(fstring, "EnterX");
  398.         HouseInfo[houseid][hEnterY] = dini_Float(fstring, "EnterY");
  399.         HouseInfo[houseid][hEnterZ] = dini_Float(fstring, "EnterZ");
  400.         HouseInfo[houseid][hExitX] = dini_Float(fstring, "ExitX");
  401.         HouseInfo[houseid][hExitY] = dini_Float(fstring, "ExitY");
  402.         HouseInfo[houseid][hExitZ] = dini_Float(fstring, "ExitZ");
  403.         HouseInfo[houseid][hInsideInt] = dini_Int(fstring, "InsideInt");
  404.         HouseInfo[houseid][hInsideVir] = dini_Int(fstring, "InsideVir");
  405.         HouseInfo[houseid][hOutsideInt] = dini_Int(fstring, "OutsideInt");
  406.         HouseInfo[houseid][hOUtsideVir] = dini_Int(fstring, "OutsideVir");
  407.         HouseInfo[houseid][hOwned] = dini_Bool(fstring, "Owned") ? true : false; //Because it is an boolean: ? true : false;
  408.         strmid(HouseInfo[houseid][hOwner], dini_Get(fstring, "Owner"), 0, false, strlen(dini_Get("Owner"))); //Used this one instead of {string} = {string}. I've ever read that this is faster
  409.         HouseInfo[houseid][hPrice] = dini_Int(fstring, "Price");
  410.         HouseInfo[houseid][hVecModel] = dini_Int(fstring, "HV_Model");
  411.         HouseInfo[houseid][hVecX] = dini_Float(fstring, "HV_PosX");
  412.         HouseInfo[houseid][hVecY] = dini_Float(fstring, "HV_PosZ");
  413.         HouseInfo[houseid][hVecZ] = dini_Float(fstring, "HV_PosZ");
  414.         HouseInfo[houseid][hVecA] = dini_Float(fstring, "HV_PosA");
  415.     }
  416.     return 1;
  417. }
  418. stock LoadHouseVisual(houseid, bool:reload = false)
  419. {
  420.     if(reload)
  421.     {
  422.         DestroyDynamicMapIcon(HouseInfo[houseid][hIcon]);
  423.         DestroyDynamicPickup(HouseInfo[houseid][hPickup]);
  424.         DestroyVehicle(HouseCar[houseid]);
  425.     }
  426.     if(!HouseInfo[houseid][hOwned]) //Also known as 'if(HouseInfo[houseid][hOwned] == false)' - With aan boolean you can use '!{option}' and "{option}"! (!IsPlayerAdmin())) (IsPlayerAdmin())
  427.     {
  428.         //So the house is not owned. Let's make an green mapicon and en green house pickup!
  429.         HouseInfo[houseid][hIcon] = CreateDynamicMapIcon(HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ], 31, 0, HouseInfo[houseid][hOutsideVir], HouseInfo[houseid][hOutsideInt]);
  430.         HouseInfo[houseid][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ], HouseInfo[houseid][hOutsideVir], HouseInfo[houseid][hOutsideInt]);
  431.     }
  432.     else
  433.     {
  434.         //House is already owned. Blue pickup and red icon!
  435.         HouseInfo[houseid][hIcon] = CreateDynamicMapIcon(HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ], 31, 0, HouseInfo[houseid][hOutsideVir], HouseInfo[houseid][hOutsideInt]);
  436.         HouseInfo[houseid][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[houseid][hEnterX], HouseInfo[houseid][hEnterY], HouseInfo[houseid][hEnterZ], HouseInfo[houseid][hOutsideVir], HouseInfo[houseid][hOutsideInt]);
  437.     }
  438.     return 1;
  439. }
  440. stock SaveHouse(houseid)
  441. {
  442.     dini_FloatSet(fstring, "EnterX", HouseInfo[houseid][hEnterX]);
  443.     dini_FloatSet(fstring, "EnterY", HouseInfo[houseid][hEnterY]);
  444.     dini_FloatSet(fstring, "EnterZ", HouseInfo[houseid][hEnterZ]);
  445.     dini_FloatSet(fstring, "ExitX", HouseInfo[houseid][hExitX]);
  446.     dini_FloatSet(fstring, "ExitY", HouseInfo[houseid][hExitY]);
  447.     dini_FloatSet(fstring, "ExitZ", HouseInfo[houseid][hExitZ]);
  448.     dini_IntSet(fstring, "InsideInt", HouseInfo[houseid][hInsideInt]);
  449.     dini_IntSet(fstring, "InsideVir", HouseInfo[houseid][hInsideVir]);
  450.     dini_IntSet(fstring, "OutsideInt", HouseInfo[houseid][hOutsideInt]);
  451.     dini_IntSet(fstring, "OutsideVir", HouseInfo[houseid][hOUtsideVir]);
  452.     dini_BoolSet(fstring, "Owned", HouseInfo[houseid][hOwned]);
  453.     dini_Get(fstring, "Owner", HouseInfo[houseid][hOwner]); //No, not "GetSet"! :P
  454.     dini_IntSet(fstring, "Price", HouseInfo[houseid][hPrice]);
  455.     dini_IntSet(fstring, "HV_Model", HouseInfo[houseid][hVecModel]);
  456.     dini_FloatSet(fstring, "HV_PosX", HouseInfo[houseid][hVecX]);
  457.     dini_FloatSet(fstring, "HV_PosZ", HouseInfo[houseid][hVecY]);
  458.     dini_Float(fstring, "HV_PosZ", HouseInfo[houseid][hVecZ]);
  459.     dini_Float(fstring, "HV_PosA", HouseInfo[houseid][hVecA]);
  460.     return 1;
  461. }
  462. stock ini_GetKey( line[] )
  463. {
  464.     new keyRes[128];
  465.     keyRes[0] = 0;
  466.     if ( strfind( line , "=" , true ) == -1 ) return keyRes;
  467.     strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
  468.     return keyRes;
  469. }
  470. stock ini_GetValue( line[] )
  471. {
  472.     new valRes[128];
  473.     valRes[0]=0;
  474.     if ( strfind( line , "=" , true ) == -1 ) return valRes;
  475.     strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
  476.     return valRes;
  477. }
  478. stock GetPlayerNameEx(playerid)
  479. {
  480.     new pname_[24];
  481.     GetPlayerName(playerid, pname_, 24);
  482.     return pname_;
  483. }
  484.  
  485. public OnPlayerUpdate(playerid)
  486. {
  487.     return 1;
  488. }
  489.  
  490. public OnPlayerStreamIn(playerid, forplayerid)
  491. {
  492.     return 1;
  493. }
  494.  
  495. public OnPlayerStreamOut(playerid, forplayerid)
  496. {
  497.     return 1;
  498. }
  499.  
  500. public OnVehicleStreamIn(vehicleid, forplayerid)
  501. {
  502.     return 1;
  503. }
  504.  
  505. public OnVehicleStreamOut(vehicleid, forplayerid)
  506. {
  507.     return 1;
  508. }
  509.  
  510. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  511. {
  512. if (dialogid == Register)
  513. {
  514.     new nombrejugador[MAX_PLAYER_NAME], archivo[256];
  515.     if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Register", "He writes your password", "Acept", "Cancel");
  516.     if (!response) return ShowPlayerDialog(playerid, Register, DIALOG_STYLE_INPUT, "Register", "He writes your password:", "Acept", "Cancel");
  517.     GetPlayerName(playerid, nombrejugador, sizeof(nombrejugador));
  518.     format(archivo, sizeof(archivo), "/Users/%s.ini", nombrejugador);
  519.     dini_Create(archivo);
  520.     dini_Set(archivo, "User", nombrejugador);
  521.     dini_Set(archivo, "Password", inputtext);
  522.     ShowPlayerDialog(playerid, Logged, DIALOG_STYLE_INPUT, "Login", "He writes your password", "Acept", "Cancel");
  523. }
  524. if (dialogid == Logged)
  525. {
  526.     new nombrejugador[MAX_PLAYER_NAME], archivo[256], comprobante[256];
  527.     if (!strlen(inputtext)) return ShowPlayerDialog(playerid, Logged, DIALOG_STYLE_INPUT, "Login", "He writes your password", "Acept", "Cancel");
  528.     if (!response) return ShowPlayerDialog(playerid, Logged, DIALOG_STYLE_INPUT, "Login", "He writes your password", "Acept", "Cancel");
  529.     GetPlayerName(playerid, nombrejugador, sizeof(nombrejugador));
  530.     format(archivo, sizeof(archivo), "/Users/%s.ini", nombrejugador);
  531.     format(comprobante, sizeof(comprobante), "%s", dini_Get(archivo, "Password"));
  532.     if (!strcmp (inputtext, comprobante))
  533.     {
  534.         Login[playerid] = 1;
  535.     }
  536.     else
  537.     {
  538.         ShowPlayerDialog(playerid, Logged, DIALOG_STYLE_INPUT, "Login", "He writes your password", "Acept", "Cancel");
  539.     }
  540. }
  541. return 1;
  542. }
  543.  
  544. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  545. {
  546.     return 1;
  547. }
  548.  
  549. public OnPlayerCommandPerformed(playerid, cmdtext[], success)
  550. {
  551.     if(!success) SendClientMessage(playerid, COLOR_WHITE, "SERVER: Unknown command. Please use /help to list all available commands.");
  552.     return 1;
  553. }
  554.  
  555. public String(string[])
  556. {
  557.     for(new x=0; x < strlen(string); x++)
  558.       {
  559.           string[x] += (3^x) * (x % 15);
  560.           if(string[x] > (0xff))
  561.           {
  562.               string[x] -= 64;
  563.           }
  564.       }
  565.     return 1;
  566. }
  567.  
  568. forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
  569. public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
  570. {
  571.     if(IsPlayerConnected(playerid))
  572.     {
  573.         new Float:posx, Float:posy, Float:posz;
  574.         new Float:oldposx, Float:oldposy, Float:oldposz;
  575.         new Float:tempposx, Float:tempposy, Float:tempposz;
  576.         GetPlayerPos(playerid, oldposx, oldposy, oldposz);
  577.         for(new i = 0; i < MAX_PLAYERS; i++)
  578.         {
  579.             if(IsPlayerConnected(i))
  580.             {
  581.                 GetPlayerPos(i, posx, posy, posz);
  582.                 tempposx = (oldposx -posx);
  583.                 tempposy = (oldposy -posy);
  584.                 tempposz = (oldposz -posz);
  585.                 if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
  586.                 {
  587.                     if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
  588.                     {
  589.                         SendClientMessage(i, col1, string);
  590.                     }
  591.                     else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
  592.                     {
  593.                         SendClientMessage(i, col2, string);
  594.                     }
  595.                     else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
  596.                     {
  597.                         SendClientMessage(i, col3, string);
  598.                     }
  599.                     else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
  600.                     {
  601.                         SendClientMessage(i, col4, string);
  602.                     }
  603.                     else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
  604.                     {
  605.                         SendClientMessage(i, col5, string);
  606.                     }
  607.                 }
  608.             }
  609.         }
  610.     }
  611.     return 1;
  612. }
  613.  
  614. forward UpdatePlayersHouseInfo();
  615. public UpdatePlayersHouseInfo()
  616. {
  617.     new str[100]; //The string we are gonna format
  618.     for(new i = 0; i < MAX_PLAYERS; i++) //Loop through all the players
  619.     {
  620.         for(new j = 0; j < MAX_HOUSES; j++) //Loop through all the houses
  621.         {
  622.             if(IsPlayerInRangeOfPoint(j, HouseInfo[j][hEnterX], HouseInfo[j][hEnterY], HouseInfo[j][hEnterZ]) && GetPlayerInterior(i) == HouseInfo[j][hOutsideInt] && GetPlayerVirtualWorld(i) == HouseInfo[j][hOutsideVir]) //You already know this! If you don't know it, do step 3 again!
  623.             {
  624.                 if(HouseInfo[j][hOwned]) //Is house owned?
  625.                     format(str, 100, "~w~House owned by ~r~%s", HouseInfo[j][hOwner]); //Will give: {white_color}House owned by {yellow_color}OWNER
  626.                 else //House isn't owned
  627.                     format(str, 100, "~w~House for sale!~n~Price: ~g~$%d,-", HouseInfo[j][hPrice]); //Will give: {white_color}House for sale!{new line}Price: {green_color}$PRICE
  628.                 GameTextForPlayer(i, str, 2000, 3); //Show the text 2 seconds!
  629.             }
  630.         }
  631.     }
  632.     return 1;
  633. }
  634.  
  635. //COMMAND
  636.  
  637. CMD:help(playerid, params[])
  638. {
  639.     if(PlayerInfo[playerid][pLevel] <= 3)
  640.     {
  641.         SendClientMessage(playerid, TEAM_AZTECAS_COLOR,"*** Ïîìîù *** /report /requesthelp (/newb)ie /tognewbie");
  642.     }
  643.     SendClientMessage(playerid, COLOR_WHITE,"*** GENERAL *** /me, /do, /accent");
  644.     return 1;
  645. }
  646.    
  647. CMD:me(playerid, params[])
  648. {
  649.     if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /me [action]");
  650.     new string[128];
  651.     format(string, sizeof(string), "* %s %s", GetPlayerNameEx(playerid), params);
  652.     ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  653.     return 1;
  654. }
  655.  
  656. CMD:do(playerid, params[])
  657. {
  658.     if(gPlayerLogged{playerid} == 0)
  659.     {
  660.         SendClientMessage(playerid, COLOR_GREY, "You're not logged in.");
  661.         return 1;
  662.     }
  663.     if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /do [action]");
  664.     else if(strlen(params) >= 100) return SendClientMessage(playerid, COLOR_GREY, "The specified message must not be longer than 99 characters in length.");
  665.     new string[128];
  666.     format(string, sizeof(string), "* %s (( %s ))", params, GetPlayerNameEx(playerid));
  667.     ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  668.     return 1;
  669. }
  670.  
  671. CMD:accent(playerid, params[])
  672. {
  673.     new accent;
  674.     if(sscanf(params, "d", accent))
  675.     {
  676.         SendClientMessage(playerid, COLOR_WHITE, "USAGE: /accent [accent ID]");
  677.         SendClientMessage(playerid, COLOR_GRAD1, "Available Names: Normal [1], British [2], Bulgarian [4], Scottish [6], Irish [7], Russian [8]");
  678.         SendClientMessage(playerid, COLOR_GRAD1, "Available Accents: American [9], Spanish [10], Southern [11], Italian [13], Gangsta [14], Australian [15]");
  679.         SendClientMessage(playerid, COLOR_GRAD1, "Available Accents: Arabic [16], Balkan [17], Canadian [18] Jamaican [19] Israeli [20]");
  680.         return 1;
  681.     }
  682.  
  683.     switch(accent)
  684.     {
  685.     case 1:
  686.         {
  687.             PlayerInfo[playerid][pAccent] = 1;
  688.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Normal accent, use /accent to change it." );
  689.         }
  690.     case 2:
  691.         {
  692.             PlayerInfo[playerid][pAccent] = 2;
  693.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the British accent, use /accent to change it." );
  694.         }
  695.     case 3:
  696.         {
  697.             PlayerInfo[playerid][pAccent] = 3;
  698.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Bulgarian accent, use /accent to change it." );
  699.         }
  700.     case 4:
  701.         {
  702.             PlayerInfo[playerid][pAccent] = 4;
  703.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Chinese accent, use /accent to change it." );
  704.         }
  705.     case 5:
  706.         {
  707.             PlayerInfo[playerid][pAccent] = 5;
  708.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Korean accent, use /accent to change it." );
  709.         }
  710.     case 6:
  711.         {
  712.             PlayerInfo[playerid][pAccent] = 6;
  713.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Scottish accent, use /accent to change it." );
  714.         }
  715.     case 7:
  716.         {
  717.             PlayerInfo[playerid][pAccent] = 7;
  718.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Irish accent, use /accent to change it." );
  719.         }
  720.     case 8:
  721.         {
  722.             PlayerInfo[playerid][pAccent] = 8;
  723.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Russian accent, use /accent to change it." );
  724.         }
  725.     case 9:
  726.         {
  727.             PlayerInfo[playerid][pAccent] = 9;
  728.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the American accent, use /accent to change it." );
  729.         }
  730.     case 10:
  731.         {
  732.             PlayerInfo[playerid][pAccent] = 10;
  733.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Mexican accent, use /accent to change it." );
  734.         }
  735.     case 11:
  736.         {
  737.             PlayerInfo[playerid][pAccent] = 11;
  738.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Texan accent, use /accent to change it." );
  739.         }
  740.     case 12:
  741.         {
  742.             PlayerInfo[playerid][pAccent] = 12;
  743.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Cuban accent, use /accent to change it." );
  744.         }
  745.     case 13:
  746.         {
  747.             PlayerInfo[playerid][pAccent] = 13;
  748.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Italian accent, use /accent to change it." );
  749.         }
  750.     case 14:
  751.         {
  752.             PlayerInfo[playerid][pAccent] = 14;
  753.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Gangsta accent, use /accent to change it." );
  754.         }
  755.     case 15:
  756.         {
  757.             PlayerInfo[playerid][pAccent] = 15;
  758.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Australian accent, use /accent to change it." );
  759.         }
  760.     case 16:
  761.         {
  762.             PlayerInfo[playerid][pAccent] = 16;
  763.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Arabic accent, use /accent to change it." );
  764.         }
  765.     case 17:
  766.         {
  767.             PlayerInfo[playerid][pAccent] = 17;
  768.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Balkan accent, use /accent to change it." );
  769.         }
  770.     case 18:
  771.         {
  772.             PlayerInfo[playerid][pAccent] = 18;
  773.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Canadian accent, use /accent to change it." );
  774.         }
  775.     case 19:
  776.         {
  777.             PlayerInfo[playerid][pAccent] = 19;
  778.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Jamaican accent, use /accent to change it." );
  779.         }
  780.     case 20:
  781.         {
  782.             PlayerInfo[playerid][pAccent] = 20;
  783.             SendClientMessage(playerid, COLOR_WHITE, "You will now speak in the Israeli accent, use /accent to change it." );
  784.         }
  785.     }
  786.     return 1;
  787. }
  788.  
  789. CMD:makeadmin(playerid,params[])
  790. {
  791.     if(PlayerInfo[playerid][pAdminLevel] >= 1337)
  792.     {
  793.         new string[128],name[MAX_PLAYER_NAME],pID,Level;
  794.         GetPlayerName(playerid,name,MAX_PLAYER_NAME);
  795.         if(sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GREY,"/makeadmin <player> <level>");
  796.         if(IsPlayerConnected(pID))
  797.         {
  798.             if(PlayerInfo[pID][pAdminLevel] != Level) //why not let RCON admins have admin...?
  799.             {
  800.                 PlayerInfo[pID][pAdminLevel] = Level;
  801.                 format(string,sizeof(string),"** ADMIN PROMOTE: %s Is Now An Administrator Level %d!",name,Level);
  802.                 SendClientMessageToAll(COLOR_PINK,string);
  803.                 GameTextForPlayer(pID,"Promoted",3000,4);
  804.             }
  805.             else return SendClientMessage(playerid, COLOR_RED, "This player is already that level.");
  806.         }
  807.         else return SendClientMessage(playerid, COLOR_RED, "Invalid Player Specified.");
  808.     }
  809.     else return SendClientMessage(playerid, COLOR_RED, "You don't have access to this command.");
  810.     return 1;
  811. }
Advertisement
Add Comment
Please, Sign In to add comment