Advertisement
garfield

[FS]: Suy House

Jul 16th, 2014
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 27.30 KB | None | 0 0
  1. #include a_samp
  2. #include dini
  3. #include zcmd
  4. #include streamer
  5.  
  6.  
  7. #define HOUSE_DEFAULT_INT               50
  8. #define MAX_HOUSES                      300
  9.  
  10. #define DIALOG_HOUSEINFO                450
  11. #define DIALOG_SAVEVEHPOS               451
  12. #define DIALOG_HOUSEINFOM               452
  13. #define DIALOG_EXPPUL                   453
  14.  
  15. enum E_HOUSES{
  16.  
  17.     bool:HOUSE_SELL,
  18.     bool:HOUSE_CARLOCKED,
  19.     bool:HOUSE_LOCKED,
  20.  
  21.     Float: PICKUP_X,
  22.     Float: PICKUP_Y,
  23.     Float: PICKUP_Z,
  24.  
  25.     Float: ENTER_X,
  26.     Float: ENTER_Y,
  27.     Float: ENTER_Z,
  28.     Float: ENTER_A,
  29.  
  30.     Float: INFO_X,
  31.     Float: INFO_Y,
  32.     Float: INFO_Z,
  33.  
  34.     Float: CARRO_X,
  35.     Float: CARRO_Y,
  36.     Float: CARRO_Z,
  37.  
  38.     HOUSE_OWNER[30],
  39.  
  40.     HOUSE_CARCOMP[14],
  41.     HOUSE_CARMODELO,
  42.     HOUSE_CARCOR[2],
  43.     HOUSE_PRECO,
  44.     HOUSE_INT,
  45.     HOUSE_VW,
  46.  
  47.     Text3D:HOUSE_TXT,
  48.     Text3D:HOUSE_EXIT,
  49.     HOUSE_PICKUPS,
  50.     HOUSE_INFOPICKUP
  51.  
  52.  
  53. }
  54. new
  55.     iHouse[MAX_HOUSES][E_HOUSES],
  56.     Text:iText[MAX_PLAYERS],
  57.     Text:svText[MAX_PLAYERS],
  58.     CASAS_CRIADAS
  59. ;
  60.  
  61.  
  62.  
  63.  
  64.  
  65. new pCar[MAX_PLAYERS];
  66. new string[200];
  67.  
  68.  
  69. stock LoadHouses(){
  70.  
  71.     static
  72.         house_str[60],
  73.         house_cnt[50],
  74.         i,e
  75.     ;
  76.  
  77.  
  78.  
  79.     for(i = 0; i != MAX_HOUSES; ++i){
  80.         format(house_str, 60,"casas/%d.reg", i);
  81.         if(fexist(house_str)){
  82.  
  83.  
  84.  
  85.  
  86.             iHouse[i][HOUSE_CARMODELO] = strval(dini_Get(house_str, "Modelo"));
  87.             iHouse[i][HOUSE_LOCKED] = bool: strval(dini_Get(house_str, "HouseLocked"));
  88.  
  89.  
  90.             iHouse[i][PICKUP_X] = dini_Float(house_str, "PickX");
  91.             iHouse[i][PICKUP_Y] = dini_Float(house_str, "PickY");
  92.             iHouse[i][PICKUP_Z] = dini_Float(house_str, "PickZ");
  93.  
  94.             iHouse[i][INFO_X]  = dini_Float(house_str, "InfoX");
  95.             iHouse[i][INFO_Y]  = dini_Float(house_str, "InfoY");
  96.             iHouse[i][INFO_Z]  = dini_Float(house_str, "InfoZ");
  97.  
  98.             iHouse[i][ENTER_X]  = dini_Float(house_str, "EnterX");
  99.             iHouse[i][ENTER_Y]  = dini_Float(house_str, "EnterY");
  100.             iHouse[i][ENTER_Z]  = dini_Float(house_str, "EnterZ");
  101.             iHouse[i][ENTER_A]  = dini_Float(house_str, "EnterA");
  102.  
  103.             iHouse[i][CARRO_X]  = dini_Float(house_str, "Carro_X");
  104.             iHouse[i][CARRO_Y]  = dini_Float(house_str, "Carro_Y");
  105.             iHouse[i][CARRO_Z]  = dini_Float(house_str, "Carro_Z");
  106.  
  107.             iHouse[i][HOUSE_INT] = strval(dini_Get(house_str, "Interior"));
  108.             iHouse[i][HOUSE_VW]  = strval(dini_Get(house_str, "VirtualWorld"));
  109.  
  110.             iHouse[i][HOUSE_SELL] = bool: strval(dini_Get(house_str, "Venda"));
  111.  
  112.             iHouse[i][HOUSE_PRECO] = strval(dini_Get(house_str, "Preco"));
  113.  
  114.             format(iHouse[i][HOUSE_OWNER], 30, dini_Get(house_str, "Dono"));
  115.  
  116.             for(e = 0; e != 13; ++e){
  117.                 format(house_cnt, 50, "Componente%d", e);
  118.                 iHouse[i][HOUSE_CARCOMP][e] = strval(dini_Get(house_str, house_cnt));
  119.  
  120.                 if(e < 2){
  121.                     format(house_cnt, 50, "Cor%d", e);
  122.                     iHouse[i][HOUSE_CARCOR][e] = strval(dini_Get(house_str, house_cnt));
  123.                 }
  124.             }
  125.  
  126.             format(house_str, 60,"Casa id:%i\nDono: %s", i, iHouse[i][HOUSE_OWNER]);
  127.             iHouse[i][HOUSE_TXT] = Create3DTextLabel(house_str, 0x008080FF, iHouse[i][PICKUP_X], iHouse[i][PICKUP_Y], iHouse[i][PICKUP_Z], 20.0, 0, 0);
  128.  
  129.             iHouse[i][HOUSE_EXIT] = Create3DTextLabel("Aperte \"F\" para sair desta residencia", 0xFFFFFF, iHouse[i][ENTER_X],iHouse[i][ENTER_Y],iHouse[i][ENTER_Z], 20.0, iHouse[i][HOUSE_VW], 0);
  130.  
  131.  
  132.             iHouse[i][HOUSE_INFOPICKUP] =  CreateDynamicPickup(1239,1,iHouse[i][INFO_X], iHouse[i][INFO_Y], iHouse[i][INFO_Z], iHouse[i][HOUSE_VW]);
  133.             iHouse[i][HOUSE_PICKUPS] = CreateDynamicPickup(1273,1,iHouse[i][PICKUP_X], iHouse[i][PICKUP_Y], iHouse[i][PICKUP_Z]);
  134.  
  135.  
  136.  
  137.             CASAS_CRIADAS ++;
  138.         }
  139.     }
  140.     return true;
  141. }
  142.  
  143. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
  144.  
  145.     if(dialogid == DIALOG_HOUSEINFOM){
  146.         if(!response){
  147.             iHouse[GetPVarInt(playerid, "playerenteredhouse")][HOUSE_CARMODELO] = 0;
  148.  
  149.             OnDialogResponse(playerid, DIALOG_HOUSEINFO, 1, 0, #);
  150.         }else{
  151.  
  152.             static
  153.                 houseid
  154.             ;
  155.  
  156.             houseid = GetPVarInt(playerid, "playerenteredhouse");
  157.  
  158.             pCar[playerid] = CreateVehicle(iHouse[houseid][HOUSE_CARMODELO], iHouse[houseid][CARRO_X],iHouse[houseid][CARRO_Y],iHouse[houseid][CARRO_Z], 0.0, -1,-1,0);
  159.  
  160.  
  161.             for(new i; i != 13; ++i) AddVehicleComponent(pCar[playerid], iHouse[houseid][HOUSE_CARCOMP][i]);
  162.  
  163.  
  164.             TextDrawSetString(svText[playerid], "Seu carro foi colocado na frente de sua casa, va pegalo!");
  165.             TextDrawShowForPlayer(playerid, svText[playerid]);
  166.  
  167.  
  168.             SetTimerEx("@ClosePlayerText", 2500, false, "i", playerid);
  169.         }
  170.     }
  171.     if(dialogid == DIALOG_HOUSEINFO){
  172.         if(response){
  173.  
  174.             static player_house_here;
  175.  
  176.             player_house_here = GetPVarInt(playerid, "playerenteredhouse");
  177.  
  178.             switch(listitem){
  179.                 case 0: {
  180.  
  181.  
  182.                     if(iHouse[player_house_here][HOUSE_CARMODELO] != 0)
  183.                     {
  184.                         format(string, sizeof(string), "%d", iHouse[player_house_here][HOUSE_CARMODELO]);
  185.                         ShowPlayerDialog(playerid, DIALOG_HOUSEINFOM, DIALOG_STYLE_LIST, "~ Residencia:Veículo pessoal ~",  string, #Pegar, #Mudar);
  186.                     }else{
  187.  
  188.                         //
  189.                         TextDrawSetString(svText[playerid], "Entre em seu ~b~veiculo ~w~para salvar salvar nesta propriedade");
  190.                         TextDrawShowForPlayer(playerid, svText[playerid]);
  191.  
  192.                         SetPVarInt(playerid, "CasaDoCarro", player_house_here);
  193.                         SetPVarInt(playerid, "SelecionandoCarro", 1);
  194.                     }
  195.                 }
  196.                 case 1:
  197.                 {
  198.                     TextDrawSetString(svText[playerid], "Voce trancou sua residencia.");
  199.                     TextDrawShowForPlayer(playerid, svText[playerid]);
  200.                 }
  201.                 case 2:{
  202.  
  203.                     if(iHouse[player_house_here][HOUSE_SELL]){
  204.                         return SendClientMessage(playerid, -1,"[INFO]: Esta casa já está avenda!");
  205.                     }
  206.  
  207.  
  208.                     static n[24]; GetPlayerName(playerid, n, 24);
  209.                     format(string, sizeof(string),"[INFO]: %s colocou está querendo sua residencia, N %i", n,  player_house_here);
  210.  
  211.                     SendClientMessageToAll(-1, string);
  212.  
  213.                     iHouse[player_house_here][HOUSE_SELL] = true;
  214.                 }
  215.                 case 3:{
  216.                     ShowPlayerDialog(playerid, DIALOG_EXPPUL, DIALOG_STYLE_INPUT, "~ Residencia: Expulsar jogador ~", "Digite o id do jogador que queiras expulsar", "Expulsar", "Cancelar");
  217.                 }
  218.             }
  219.         }
  220.     }
  221.  
  222.     if(dialogid == DIALOG_EXPPUL){
  223.         if(response){
  224.             static tmp_id;
  225.  
  226.             tmp_id = strval(inputtext);
  227.  
  228.             if(!IsPlayerConnected(tmp_id)){
  229.                 return SendClientMessage(playerid, -1, "[ERRO]: Este jogador não está online!");
  230.             }
  231.  
  232.             static tmp_houseid;
  233.  
  234.             tmp_houseid = GetPVarInt(playerid, "playerenteredhouse");
  235.             if(tmp_houseid != GetPVarInt(tmp_id,  "playerenteredhouse")){
  236.                 return SendClientMessage(playerid, -1, "[ERRO]: Este jogador não está em sua casa!");
  237.             }
  238.  
  239.  
  240.             SetPlayerInterior(tmp_id, 0);
  241.             SetPlayerVirtualWorld(tmp_id, 0);
  242.             SetPlayerPos(tmp_id, iHouse[tmp_houseid][PICKUP_X],iHouse[tmp_houseid][PICKUP_Y],iHouse[tmp_houseid][PICKUP_Z]);
  243.  
  244.             static n[24];
  245.  
  246.             GetPlayerName(playerid, n, 24);
  247.  
  248.             format(string, sizeof(string), "O Jogador %s te expulsou da casa dele.",n ); SendClientMessage(tmp_id, -1, string);
  249.  
  250.             GetPlayerName(tmp_id, n, 24);
  251.             format(string, sizeof(string), "Você expulsou o %s de sua casa.",n ); SendClientMessage(playerid, -1, string);
  252.  
  253.  
  254.         }
  255.     }
  256.     return true;
  257. }
  258.  
  259.  
  260.  
  261. public OnPlayerStateChange(playerid, newstate, oldstate){
  262.  
  263.     if(newstate == PLAYER_STATE_DRIVER){
  264.  
  265.         if(GetPVarInt(playerid, "SelecionandoCarro") == 1){
  266.             TextDrawSetString(svText[playerid], "Agora, estacione seu veiculo.. digite ~y~/Tunar~n~~w~para tunar seu veiculo Aperte~g~~h~~h~ y ~w~ para salvar.");
  267.             TextDrawShowForPlayer(playerid, svText[playerid]);
  268.  
  269.             SetPVarInt(playerid, "SelecionandoCarro", 2);
  270.         }
  271.     }
  272.     return true;
  273. }
  274.  
  275.  
  276.  
  277. public OnPlayerPickUpDynamicPickup(playerid, pickupid){
  278.  
  279.     if(pickupid >= iHouse[0][HOUSE_INFOPICKUP] || pickupid <= iHouse[CASAS_CRIADAS - 1][HOUSE_INFOPICKUP]){
  280.  
  281.         if(GetPVarInt(playerid, "playerenteredhouse") != -1 && GetPlayerInterior(playerid) != 0 && GetPlayerVirtualWorld(playerid) != 0){
  282.  
  283.  
  284.             if( (gettime() - GetPVarInt(playerid, "__dialogspam")) > 2 ){
  285.  
  286.                 ShowPlayerDialog(playerid, DIALOG_HOUSEINFO, DIALOG_STYLE_LIST, "~ Residencia ~", "Veiculo pessoal\nTrancar casa\nVender Casa\nExpulsar player de sua casa", "Selecionar", "Fechar");
  287.  
  288.                 SetPVarInt(playerid, "__dialogspam", gettime());
  289.             }
  290.  
  291.         }
  292.     }
  293.  
  294.  
  295.  
  296.     static houseid;
  297.     for(houseid = 0; houseid != CASAS_CRIADAS; ++houseid)
  298.     {
  299.         if(IsPlayerInRangeOfPoint(playerid, 1.5, iHouse[houseid][PICKUP_X], iHouse[houseid][PICKUP_Y], iHouse[houseid][PICKUP_Z])){
  300.  
  301.             if( (gettime() - GetPVarInt(playerid, "__housespam")) > 2 ){
  302.  
  303.  
  304.                 static
  305.                     _strhouseshow[200]
  306.                 ;
  307.  
  308.  
  309.                 format(_strhouseshow, 200, "Casa: %i~n~Preco: %i~n~Dono: %s~n~A Venda: %s~n~Veiculo: %d",houseid, iHouse[houseid][HOUSE_PRECO],iHouse[houseid][HOUSE_OWNER],
  310.                 iHouse[houseid][HOUSE_SELL] ? ("Sim") : ("Nao"),  iHouse[houseid][HOUSE_CARMODELO]);
  311.  
  312.                // printf(_strhouseshow);
  313.                 TextDrawSetString(iText[playerid], _strhouseshow);
  314.                 TextDrawShowForPlayer(playerid, iText[playerid]);
  315.  
  316.                 SetPVarInt(playerid, "__playerinhouse", 1);
  317.                 SetTimerEx("@OnPlayerDynamicHouse", 1000, false, "i", playerid);
  318.  
  319.                 SetPVarInt(playerid, "inhouseid", houseid);
  320.  
  321.                 SetPVarInt(playerid, "__housespam", gettime());
  322.             }
  323.  
  324.         }
  325.     }
  326.     return true;
  327. }
  328.  
  329. OnPlayerLeaveDynamicHouse(playerid, houseid); public OnPlayerLeaveDynamicHouse(playerid, houseid){
  330.  
  331.  
  332.  
  333.     format(string, sizeof(string),"Você saiu da casa: %d", houseid);
  334.     //SendClientMessage(playerid, -1, string);
  335.  
  336.     SetPVarInt(playerid, "inhouseid", -1);
  337.     TextDrawHideForPlayer(playerid, iText[playerid]);
  338.     return true;
  339. }
  340.  
  341. forward @OnPlayerDynamicHouse(playerid); public @OnPlayerDynamicHouse(playerid){
  342.  
  343.     if(GetPVarInt(playerid, "__playerinhouse"))
  344.     {
  345.         static per, esta;
  346.  
  347.         esta = -1;
  348.  
  349.         for(per = 0; per != CASAS_CRIADAS; ++per){
  350.             if(IsPlayerInRangeOfPoint(playerid, 1.5, iHouse[per][PICKUP_X], iHouse[per][PICKUP_Y], iHouse[per][PICKUP_Z])){
  351.                 esta = per;
  352.                 break;
  353.             }
  354.         }
  355.  
  356.  
  357.        // printf("esta: %d == -1", esta);
  358.         if(esta == -1)
  359.             return CallLocalFunction("OnPlayerLeaveDynamicHouse", "ii", playerid, esta);
  360.  
  361.         SetTimerEx("@OnPlayerDynamicHouse", 800, false, "i", playerid);
  362.     }
  363.     return true;
  364. }
  365.  
  366.  
  367. public OnFilterScriptExit(){
  368.  
  369.     for(new i; i != CASAS_CRIADAS; ++i) Delete3DTextLabel(iHouse[i][HOUSE_TXT]), Delete3DTextLabel(iHouse[i][HOUSE_EXIT]);
  370.     for(new i; i != CASAS_CRIADAS; ++i) DestroyDynamicPickup(iHouse[i][HOUSE_PICKUPS]), DestroyDynamicPickup(iHouse[i][HOUSE_INFOPICKUP]);
  371.     for(new i; i != MAX_PLAYERS; ++i) TextDrawDestroy(iText[i]),TextDrawDestroy(svText[i]),OnPlayerDisconnect(i, 0);
  372.     return false;
  373. }
  374.  
  375.  
  376.  
  377. public OnFilterScriptInit(){
  378.  
  379.     DisableInteriorEnterExits();
  380.  
  381.  
  382.  
  383.     static timer;
  384.     timer = gettime();
  385.  
  386.     LoadHouses();
  387.     printf("\n\n\nDemorou %d segundos para carregar as casas.\n\n\n", gettime() - timer);
  388.  
  389.     for(new i; i != MAX_PLAYERS; ++i){
  390.         iText[i] = TextDrawCreate(145.000000, 357.000000, "Casa: 60~n~Preco: 735~n~Dono: Nenhum~n~A Venda: Nao~n~");
  391.         TextDrawBackgroundColor(iText[i], 255);
  392.         TextDrawFont(iText[i], 1);
  393.         TextDrawLetterSize(iText[i], 0.289999, 1.500000);
  394.         TextDrawColor(iText[i], -1);
  395.         TextDrawSetOutline(iText[i], 1);
  396.         TextDrawSetProportional(iText[i], 1);
  397.         TextDrawUseBox(iText[i], 1);
  398.         TextDrawBoxColor(iText[i], 85);
  399.         TextDrawTextSize(iText[i], 260.000000, 0.000000);
  400.  
  401.  
  402.         svText[i] = TextDrawCreate(259.000000, 371.000000, "Entre em seu veiculo para salvar nesta propriedade");
  403.         TextDrawBackgroundColor(svText[i], 255);
  404.         TextDrawFont(svText[i], 1);
  405.         TextDrawLetterSize(svText[i], 0.240000, 1.000000);
  406.         TextDrawColor(svText[i], -1);
  407.         TextDrawSetOutline(svText[i], 1);
  408.         TextDrawSetProportional(svText[i], 1);
  409.  
  410.     }
  411.  
  412.     return true;
  413. }
  414.  
  415.  
  416.  
  417. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys){
  418.  
  419.     if(newkeys & KEY_YES)
  420.     {
  421.  
  422.         if(GetPVarInt(playerid, "SelecionandoCarro") == 2)
  423.         {
  424.             static houseid;
  425.  
  426.             houseid = GetPVarInt(playerid, "CasaDoCarro");
  427.  
  428.             if(!IsPlayerInRangeOfPoint(playerid, 25.0, iHouse[houseid][PICKUP_X], iHouse[houseid][PICKUP_Y], iHouse[houseid][PICKUP_Z]))
  429.             {
  430.                 TextDrawSetString(svText[playerid], "~r~ERRO:~w~Voce deve estar perto de sua casa!");
  431.                 TextDrawShowForPlayer(playerid, svText[playerid]);
  432.             }else
  433.             {
  434.                 SetPVarInt(playerid, "SelecionandoCarro", 0);
  435.                 SetPVarInt(playerid, "CasaDoCarro", -1);
  436.  
  437.                 TextDrawSetString(svText[playerid], "~g~~h~~h~Pronto ~w~veiculo salvo com sucesso!");
  438.                 TextDrawShowForPlayer(playerid, svText[playerid]);
  439.  
  440.                 format(string, sizeof(string), "/casas/%d.reg", houseid);
  441.  
  442.                 static player_vehicle;
  443.  
  444.                 player_vehicle = GetPlayerVehicleID(playerid);
  445.  
  446.                 iHouse[houseid][HOUSE_CARMODELO] = GetVehicleModel(player_vehicle);
  447.  
  448.  
  449.                 dini_IntSet(string, "Modelo", GetVehicleModel(GetPlayerVehicleID(playerid)));
  450.  
  451.                 iHouse[houseid][HOUSE_CARCOMP][0] = GetVehicleComponentInSlot(player_vehicle, CARMODTYPE_SPOILER);
  452.                 iHouse[houseid][HOUSE_CARCOMP][1] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_HOOD);
  453.                 iHouse[houseid][HOUSE_CARCOMP][2] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_ROOF);
  454.                 iHouse[houseid][HOUSE_CARCOMP][3] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_SIDESKIRT);
  455.                 iHouse[houseid][HOUSE_CARCOMP][4] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_LAMPS);
  456.                 iHouse[houseid][HOUSE_CARCOMP][5] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_NITRO);
  457.                 iHouse[houseid][HOUSE_CARCOMP][6] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_EXHAUST);
  458.                 iHouse[houseid][HOUSE_CARCOMP][7] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_WHEELS);
  459.                 iHouse[houseid][HOUSE_CARCOMP][8] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_STEREO);
  460.                 iHouse[houseid][HOUSE_CARCOMP][9] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_HYDRAULICS);
  461.                 iHouse[houseid][HOUSE_CARCOMP][10] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_FRONT_BUMPER);
  462.                 iHouse[houseid][HOUSE_CARCOMP][11] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_REAR_BUMPER);
  463.                 iHouse[houseid][HOUSE_CARCOMP][12] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_VENT_RIGHT);
  464.                 iHouse[houseid][HOUSE_CARCOMP][13] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_VENT_LEFT);
  465.  
  466.  
  467.  
  468.                 static
  469.                     Float: tmp_POS[3],
  470.                     tmp_sv_str[15],
  471.                     int
  472.                 ;
  473.  
  474.  
  475.                 tmp_sv_str[0] = '\0';
  476.  
  477.  
  478.                 for(int = 0; int != 13; ++int){
  479.                     format(tmp_sv_str, sizeof(tmp_sv_str),"Componente%i", int);
  480.                     dini_IntSet(string, tmp_sv_str, iHouse[houseid][HOUSE_CARCOMP][int]);
  481.                 }
  482.  
  483.  
  484.                 GetVehiclePos(player_vehicle, tmp_POS[0], tmp_POS[1],tmp_POS[2]);
  485.                 dini_FloatSet(string, "Carro_X", tmp_POS[0]);
  486.                 dini_FloatSet(string, "Carro_Y", tmp_POS[1]);
  487.                 dini_FloatSet(string, "Carro_Z", tmp_POS[2]);
  488.  
  489.  
  490.                 iHouse[houseid][CARRO_X] = tmp_POS[0];
  491.                 iHouse[houseid][CARRO_Y] = tmp_POS[1];
  492.                 iHouse[houseid][CARRO_Z] = tmp_POS[2];
  493.  
  494.                 SetTimerEx("@ClosePlayerText", 1500, false, "i", playerid);
  495.             }
  496.  
  497.         }
  498.     }
  499.     if(newkeys & KEY_SECONDARY_ATTACK){
  500.  
  501.         if(GetPVarInt(playerid, "playerenteredhouse") == -1) {
  502.  
  503.             static houseid;
  504.  
  505.             houseid = GetPVarInt(playerid, "inhouseid");
  506.  
  507.             if(houseid != -1){
  508.  
  509.  
  510.                 static pnome[24];
  511.  
  512.                 GetPlayerName(playerid, pnome, 24);
  513.  
  514.                 if(!strcmp(iHouse[houseid][HOUSE_OWNER], pnome, true)){
  515.  
  516.                     SetPlayerVirtualWorld(playerid, iHouse[houseid][HOUSE_VW]);
  517.  
  518.                     SetPlayerPos(playerid, iHouse[houseid][ENTER_X],iHouse[houseid][ENTER_Y],iHouse[houseid][ENTER_Z]);
  519.                     SetPlayerInterior(playerid, iHouse[houseid][HOUSE_INT]);
  520.  
  521.                     SetPVarInt(playerid, "playerenteredhouse", houseid);
  522.                     return true;
  523.                 }
  524.             }
  525.         }
  526.  
  527.         if(GetPVarInt(playerid, "playerenteredhouse") != -1){
  528.  
  529.             static houseid;
  530.  
  531.             houseid = GetPVarInt(playerid, "playerenteredhouse");
  532.             if(IsPlayerInRangeOfPoint(playerid, 2.0, iHouse[houseid][ENTER_X],iHouse[houseid][ENTER_Y],iHouse[houseid][ENTER_Z]))
  533.             {
  534.  
  535.                 SetPlayerVirtualWorld(playerid, 0);
  536.  
  537.                 SetPlayerPos(playerid, iHouse[houseid][PICKUP_X],iHouse[houseid][PICKUP_Y],iHouse[houseid][PICKUP_Z]);
  538.                 SetPlayerInterior(playerid, 0);
  539.  
  540.                 SetPVarInt(playerid, "playerenteredhouse", -1);
  541.             }
  542.         }
  543.     }
  544.     return true;
  545. }
  546. forward @ClosePlayerText(playerid); public @ClosePlayerText(playerid){
  547.  
  548.     TextDrawHideForPlayer(playerid, svText[playerid]);
  549.     return true;
  550. }
  551. public OnPlayerDisconnect(playerid, reason){
  552.     SetPVarInt(playerid, "playerenteredhouse", -1);
  553.     SetPVarInt(playerid, "inhouseid",   -1);
  554.     return true;
  555. }
  556.  
  557. public OnPlayerConnect(playerid){
  558.     SetPVarInt(playerid, "playerenteredhouse", -1);
  559.     return true;
  560. }
  561.  
  562. CMD:inter(playerid, params[]){
  563.     SetPlayerInterior(playerid,  12);
  564.     SetPlayerPos(playerid, 2324.419921,-1145.568359,1050.710083);
  565.     return true;
  566. }
  567.  
  568. CMD:comprar(playerid, params[]){
  569.  
  570.     if(GetPVarInt(playerid, "inhouseid") == -1){
  571.         return SendClientMessage(playerid, -1,"[INFO]: Você não está em uma residência!");
  572.     }
  573.  
  574.     static
  575.         houseid
  576.     ;
  577.  
  578.     houseid =  GetPVarInt(playerid, "inhouseid");
  579.  
  580.     if(!iHouse[houseid][HOUSE_SELL]){
  581.         return SendClientMessage(playerid, -1,"[INFO]: Esta casa não está à venda");
  582.     }
  583.  
  584.     if(GetPlayerMoney(playerid) < iHouse[houseid][HOUSE_PRECO]){
  585.         return SendClientMessage(playerid, -1,"[INFO]: Você não tem dinheiro suficiente para comprar esta casa!");
  586.     }
  587.  
  588.  
  589.  
  590.     static
  591.         _tmpstr[128],
  592.         nomej[24]
  593.     ;
  594.  
  595.     GetPlayerName(playerid, nomej, 24);
  596.  
  597.     //GivePlayerMoney(playerid, -iHouse[houseid][HOUSE_PRECO]);
  598.  
  599.     format(_tmpstr, 128,"casas/%d.reg", houseid);
  600.  
  601.     dini_Set(_tmpstr, "Dono", nomej);
  602.     dini_IntSet(_tmpstr, "Venda", 0);
  603.  
  604.     iHouse[houseid][HOUSE_SELL] = false;
  605.     format(iHouse[houseid][HOUSE_OWNER], 30, nomej);
  606.  
  607.     format(_tmpstr, 128, "Casa: %i~n~Preco: %i~n~Dono: %s~n~A Venda: %s~n~Veiculo: %d",houseid, iHouse[houseid][HOUSE_PRECO],iHouse[houseid][HOUSE_OWNER], iHouse[houseid][HOUSE_SELL] ? ("Sim") : ("Nao"),  iHouse[houseid][HOUSE_CARMODELO]);
  608.     TextDrawSetString(iText[playerid], _tmpstr);
  609.     TextDrawShowForPlayer(playerid, iText[playerid]);
  610.  
  611.     format(_tmpstr, 128, "Casa id:%i\nDono: %s",houseid, nomej);
  612.     Update3DTextLabelText(iHouse[houseid][HOUSE_TXT], 0x008080FF, _tmpstr);
  613.  
  614.     format(_tmpstr, 128,"[INFO]: Você comprou a residencia por R$: %d, aperte \"F\" para poder entrar.", iHouse[houseid][HOUSE_PRECO]);
  615.     SendClientMessage(playerid, -1, _tmpstr);
  616.  
  617.     return true;
  618. }
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626. CMD:casa(playerid, params[]){
  627.  
  628.  
  629.     static
  630.         preco
  631.     ;
  632.  
  633.     if(sscanf(params, "i", preco)){
  634.         return SendClientMessage(playerid, -1,"[INFO]: /casa <preco>");
  635.     }
  636.  
  637.     static
  638.         house_str[60],
  639.         Float: _Pos[3],
  640.         i
  641.     ;
  642.  
  643.     for(i = 0; i != MAX_HOUSES; ++i){
  644.         format(house_str, 60, "/casas/%d.reg", i);
  645.  
  646.         if(!fexist(house_str)) break;
  647.     }
  648.  
  649.     fclose(fopen(house_str, io_write));
  650.  
  651.     GetPlayerPos(playerid, _Pos[0], _Pos[1], _Pos[2]);
  652.  
  653.     dini_IntSet(house_str, "Preco", preco);
  654.     dini_FloatSet(house_str, "PickX",_Pos[0]);
  655.     dini_FloatSet(house_str, "PickY",_Pos[1]);
  656.     dini_FloatSet(house_str, "PickZ",_Pos[2]);
  657.  
  658.     dini_FloatSet(house_str, "EnterX", 235.34);
  659.     dini_FloatSet(house_str, "EnterY", 1186.68);          //  SetPlayerPos(playerid, 235.34,1186.68,1080.26);
  660.     dini_FloatSet(house_str, "EnterZ", 1080.26);
  661.     dini_FloatSet(house_str, "EnterA", 357.4933);
  662.  
  663.     dini_IntSet(house_str, "Modelo", 0);
  664.     dini_IntSet(house_str, "HouseLocked", 0);
  665.     dini_IntSet(house_str, "Interior", 3);
  666.     dini_IntSet(house_str, "VirtualWorld", HOUSE_DEFAULT_INT + CASAS_CRIADAS);
  667.  
  668.     CreateDynamicMapIcon(_Pos[0], _Pos[1], _Pos[2], 0, 0xC0C0C0FF);
  669.  
  670.     format(string, sizeof(string), "Você criou a casas N %i, X: %f, Y: %f, Z: %f", CASAS_CRIADAS, _Pos[0], _Pos[1], _Pos[2]);
  671.     SendClientMessage(playerid, -1, string);
  672.  
  673.     CASAS_CRIADAS ++;
  674.     return true;
  675. }
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688. stock sscanf(_stsadasstring[], format[], {Float,_}:...)
  689. {
  690.     #if defined isnull
  691.         if (isnull(_stsadasstring))
  692.     #else
  693.         if (_stsadasstring[0] == 0 || (_stsadasstring[0] == 1 && _stsadasstring[1] == 0))
  694.     #endif
  695.         {
  696.             return format[0];
  697.         }
  698.     #pragma tabsize 4
  699.     new
  700.         formatPos = 0,
  701.         _stsadasstringPos = 0,
  702.         paramPos = 2,
  703.         paramCount = numargs(),
  704.         delim = ' ';
  705.     while (_stsadasstring[_stsadasstringPos] && _stsadasstring[_stsadasstringPos] <= ' ')
  706.     {
  707.         _stsadasstringPos++;
  708.     }
  709.     while (paramPos < paramCount && _stsadasstring[_stsadasstringPos])
  710.     {
  711.         switch (format[formatPos++])
  712.         {
  713.             case '\0':
  714.             {
  715.                 return 0;
  716.             }
  717.             case 'i', 'd':
  718.             {
  719.                 new
  720.                     neg = 1,
  721.                     num = 0,
  722.                     ch = _stsadasstring[_stsadasstringPos];
  723.                 if (ch == '-')
  724.                 {
  725.                     neg = -1;
  726.                     ch = _stsadasstring[++_stsadasstringPos];
  727.                 }
  728.                 do
  729.                 {
  730.                     _stsadasstringPos++;
  731.                     if ('0' <= ch <= '9')
  732.                     {
  733.                         num = (num * 10) + (ch - '0');
  734.                     }
  735.                     else
  736.                     {
  737.                         return -1;
  738.                     }
  739.                 }
  740.                 while ((ch = _stsadasstring[_stsadasstringPos]) > ' ' && ch != delim);
  741.                 setarg(paramPos, 0, num * neg);
  742.             }
  743.             case 'h', 'x':
  744.             {
  745.                 new
  746.                     num = 0,
  747.                     ch = _stsadasstring[_stsadasstringPos];
  748.                 do
  749.                 {
  750.                     _stsadasstringPos++;
  751.                     switch (ch)
  752.                     {
  753.                         case 'x', 'X':
  754.                         {
  755.                             num = 0;
  756.                             continue;
  757.                         }
  758.                         case '0' .. '9':
  759.                         {
  760.                             num = (num << 4) | (ch - '0');
  761.                         }
  762.                         case 'a' .. 'f':
  763.                         {
  764.                             num = (num << 4) | (ch - ('a' - 10));
  765.                         }
  766.                         case 'A' .. 'F':
  767.                         {
  768.                             num = (num << 4) | (ch - ('A' - 10));
  769.                         }
  770.                         default:
  771.                         {
  772.                             return -1;
  773.                         }
  774.                     }
  775.                 }
  776.                 while ((ch = _stsadasstring[_stsadasstringPos]) > ' ' && ch != delim);
  777.                 setarg(paramPos, 0, num);
  778.             }
  779.             case 'c':
  780.             {
  781.                 setarg(paramPos, 0, _stsadasstring[_stsadasstringPos++]);
  782.             }
  783.             case 'f':
  784.             {
  785.  
  786.                 new changestr[16], changepos = 0, strpos = _stsadasstringPos;
  787.                 while(changepos < 16 && _stsadasstring[strpos] && _stsadasstring[strpos] != delim)
  788.                 {
  789.                     changestr[changepos++] = _stsadasstring[strpos++];
  790.                     }
  791.                 changestr[changepos] = '\0';
  792.                 setarg(paramPos,0,_:floatstr(changestr));
  793.             }
  794.             case 'p':
  795.             {
  796.                 delim = format[formatPos++];
  797.                 continue;
  798.             }
  799.             case '\'':
  800.             {
  801.                 new
  802.                     end = formatPos - 1,
  803.                     ch;
  804.                 while ((ch = format[++end]) && ch != '\'') {}
  805.                 if (!ch)
  806.                 {
  807.                     return -1;
  808.                 }
  809.                 format[end] = '\0';
  810.                 if ((ch = strfind(_stsadasstring, format[formatPos], false, _stsadasstringPos)) == -1)
  811.                 {
  812.                     if (format[end + 1])
  813.                     {
  814.                         return -1;
  815.                     }
  816.                     return 0;
  817.                 }
  818.                 format[end] = '\'';
  819.                 _stsadasstringPos = ch + (end - formatPos);
  820.                 formatPos = end + 1;
  821.             }
  822.             case 'u':
  823.             {
  824.                 new
  825.                     end = _stsadasstringPos - 1,
  826.                     id = 0,
  827.                     bool:num = true,
  828.                     ch;
  829.                 while ((ch = _stsadasstring[++end]) && ch != delim)
  830.                 {
  831.                     if (num)
  832.                     {
  833.                         if ('0' <= ch <= '9')
  834.                         {
  835.                             id = (id * 10) + (ch - '0');
  836.                         }
  837.                         else
  838.                         {
  839.                             num = false;
  840.                         }
  841.                     }
  842.                 }
  843.                 if (num && IsPlayerConnected(id))
  844.                 {
  845.                     setarg(paramPos, 0, id);
  846.                 }
  847.                 else
  848.                 {
  849.                     #if !defined foreach
  850.                         #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  851.                         #define __SSCANF_FOREACH__
  852.                     #endif
  853.                     _stsadasstring[end] = '\0';
  854.                     num = false;
  855.                     new
  856.                         name[MAX_PLAYER_NAME];
  857.                     id = end - _stsadasstringPos;
  858.                     foreach (Player, playerid)
  859.                     {
  860.                         GetPlayerName(playerid, name, sizeof (name));
  861.                         if (!strcmp(name, _stsadasstring[_stsadasstringPos], true, id))
  862.                         {
  863.                             setarg(paramPos, 0, playerid);
  864.                             num = true;
  865.                             break;
  866.                         }
  867.                     }
  868.                     if (!num)
  869.                     {
  870.                         setarg(paramPos, 0, INVALID_PLAYER_ID);
  871.                     }
  872.                     _stsadasstring[end] = ch;
  873.                     #if defined __SSCANF_FOREACH__
  874.                         #undef foreach
  875.                         #undef __SSCANF_FOREACH__
  876.                     #endif
  877.                 }
  878.                 _stsadasstringPos = end;
  879.             }
  880.             case 's', 'z':
  881.             {
  882.                 new
  883.                     i = 0,
  884.                     ch;
  885.                 if (format[formatPos])
  886.                 {
  887.                     while ((ch = _stsadasstring[_stsadasstringPos++]) && ch != delim)
  888.                     {
  889.                         setarg(paramPos, i++, ch);
  890.                     }
  891.                     if (!i)
  892.                     {
  893.                         return -1;
  894.                     }
  895.                 }
  896.                 else
  897.                 {
  898.                     while ((ch = _stsadasstring[_stsadasstringPos++]))
  899.                     {
  900.                         setarg(paramPos, i++, ch);
  901.                     }
  902.                 }
  903.                 _stsadasstringPos--;
  904.                 setarg(paramPos, i, '\0');
  905.             }
  906.             default:
  907.             {
  908.                 continue;
  909.             }
  910.         }
  911.         while (_stsadasstring[_stsadasstringPos] && _stsadasstring[_stsadasstringPos] != delim && _stsadasstring[_stsadasstringPos] > ' ')
  912.         {
  913.             _stsadasstringPos++;
  914.         }
  915.         while (_stsadasstring[_stsadasstringPos] && (_stsadasstring[_stsadasstringPos] == delim || _stsadasstring[_stsadasstringPos] <= ' '))
  916.         {
  917.             _stsadasstringPos++;
  918.         }
  919.         paramPos++;
  920.     }
  921.     do
  922.     {
  923.         if ((delim = format[formatPos++]) > ' ')
  924.         {
  925.             if (delim == '\'')
  926.             {
  927.                 while ((delim = format[formatPos++]) && delim != '\'') {}
  928.             }
  929.             else if (delim != 'z')
  930.             {
  931.                 return delim;
  932.             }
  933.         }
  934.     }
  935.     while (delim > ' ');
  936.     return 0;
  937. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement