Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include a_samp
- #include dini
- #include zcmd
- #include streamer
- #define HOUSE_DEFAULT_INT 50
- #define MAX_HOUSES 300
- #define DIALOG_HOUSEINFO 450
- #define DIALOG_SAVEVEHPOS 451
- #define DIALOG_HOUSEINFOM 452
- #define DIALOG_EXPPUL 453
- enum E_HOUSES{
- bool:HOUSE_SELL,
- bool:HOUSE_CARLOCKED,
- bool:HOUSE_LOCKED,
- Float: PICKUP_X,
- Float: PICKUP_Y,
- Float: PICKUP_Z,
- Float: ENTER_X,
- Float: ENTER_Y,
- Float: ENTER_Z,
- Float: ENTER_A,
- Float: INFO_X,
- Float: INFO_Y,
- Float: INFO_Z,
- Float: CARRO_X,
- Float: CARRO_Y,
- Float: CARRO_Z,
- HOUSE_OWNER[30],
- HOUSE_CARCOMP[14],
- HOUSE_CARMODELO,
- HOUSE_CARCOR[2],
- HOUSE_PRECO,
- HOUSE_INT,
- HOUSE_VW,
- Text3D:HOUSE_TXT,
- Text3D:HOUSE_EXIT,
- HOUSE_PICKUPS,
- HOUSE_INFOPICKUP
- }
- new
- iHouse[MAX_HOUSES][E_HOUSES],
- Text:iText[MAX_PLAYERS],
- Text:svText[MAX_PLAYERS],
- CASAS_CRIADAS
- ;
- new pCar[MAX_PLAYERS];
- new string[200];
- stock LoadHouses(){
- static
- house_str[60],
- house_cnt[50],
- i,e
- ;
- for(i = 0; i != MAX_HOUSES; ++i){
- format(house_str, 60,"casas/%d.reg", i);
- if(fexist(house_str)){
- iHouse[i][HOUSE_CARMODELO] = strval(dini_Get(house_str, "Modelo"));
- iHouse[i][HOUSE_LOCKED] = bool: strval(dini_Get(house_str, "HouseLocked"));
- iHouse[i][PICKUP_X] = dini_Float(house_str, "PickX");
- iHouse[i][PICKUP_Y] = dini_Float(house_str, "PickY");
- iHouse[i][PICKUP_Z] = dini_Float(house_str, "PickZ");
- iHouse[i][INFO_X] = dini_Float(house_str, "InfoX");
- iHouse[i][INFO_Y] = dini_Float(house_str, "InfoY");
- iHouse[i][INFO_Z] = dini_Float(house_str, "InfoZ");
- iHouse[i][ENTER_X] = dini_Float(house_str, "EnterX");
- iHouse[i][ENTER_Y] = dini_Float(house_str, "EnterY");
- iHouse[i][ENTER_Z] = dini_Float(house_str, "EnterZ");
- iHouse[i][ENTER_A] = dini_Float(house_str, "EnterA");
- iHouse[i][CARRO_X] = dini_Float(house_str, "Carro_X");
- iHouse[i][CARRO_Y] = dini_Float(house_str, "Carro_Y");
- iHouse[i][CARRO_Z] = dini_Float(house_str, "Carro_Z");
- iHouse[i][HOUSE_INT] = strval(dini_Get(house_str, "Interior"));
- iHouse[i][HOUSE_VW] = strval(dini_Get(house_str, "VirtualWorld"));
- iHouse[i][HOUSE_SELL] = bool: strval(dini_Get(house_str, "Venda"));
- iHouse[i][HOUSE_PRECO] = strval(dini_Get(house_str, "Preco"));
- format(iHouse[i][HOUSE_OWNER], 30, dini_Get(house_str, "Dono"));
- for(e = 0; e != 13; ++e){
- format(house_cnt, 50, "Componente%d", e);
- iHouse[i][HOUSE_CARCOMP][e] = strval(dini_Get(house_str, house_cnt));
- if(e < 2){
- format(house_cnt, 50, "Cor%d", e);
- iHouse[i][HOUSE_CARCOR][e] = strval(dini_Get(house_str, house_cnt));
- }
- }
- format(house_str, 60,"Casa id:%i\nDono: %s", i, iHouse[i][HOUSE_OWNER]);
- iHouse[i][HOUSE_TXT] = Create3DTextLabel(house_str, 0x008080FF, iHouse[i][PICKUP_X], iHouse[i][PICKUP_Y], iHouse[i][PICKUP_Z], 20.0, 0, 0);
- 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);
- iHouse[i][HOUSE_INFOPICKUP] = CreateDynamicPickup(1239,1,iHouse[i][INFO_X], iHouse[i][INFO_Y], iHouse[i][INFO_Z], iHouse[i][HOUSE_VW]);
- iHouse[i][HOUSE_PICKUPS] = CreateDynamicPickup(1273,1,iHouse[i][PICKUP_X], iHouse[i][PICKUP_Y], iHouse[i][PICKUP_Z]);
- CASAS_CRIADAS ++;
- }
- }
- return true;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
- if(dialogid == DIALOG_HOUSEINFOM){
- if(!response){
- iHouse[GetPVarInt(playerid, "playerenteredhouse")][HOUSE_CARMODELO] = 0;
- OnDialogResponse(playerid, DIALOG_HOUSEINFO, 1, 0, #);
- }else{
- static
- houseid
- ;
- houseid = GetPVarInt(playerid, "playerenteredhouse");
- pCar[playerid] = CreateVehicle(iHouse[houseid][HOUSE_CARMODELO], iHouse[houseid][CARRO_X],iHouse[houseid][CARRO_Y],iHouse[houseid][CARRO_Z], 0.0, -1,-1,0);
- for(new i; i != 13; ++i) AddVehicleComponent(pCar[playerid], iHouse[houseid][HOUSE_CARCOMP][i]);
- TextDrawSetString(svText[playerid], "Seu carro foi colocado na frente de sua casa, va pegalo!");
- TextDrawShowForPlayer(playerid, svText[playerid]);
- SetTimerEx("@ClosePlayerText", 2500, false, "i", playerid);
- }
- }
- if(dialogid == DIALOG_HOUSEINFO){
- if(response){
- static player_house_here;
- player_house_here = GetPVarInt(playerid, "playerenteredhouse");
- switch(listitem){
- case 0: {
- if(iHouse[player_house_here][HOUSE_CARMODELO] != 0)
- {
- format(string, sizeof(string), "%d", iHouse[player_house_here][HOUSE_CARMODELO]);
- ShowPlayerDialog(playerid, DIALOG_HOUSEINFOM, DIALOG_STYLE_LIST, "~ Residencia:Veículo pessoal ~", string, #Pegar, #Mudar);
- }else{
- //
- TextDrawSetString(svText[playerid], "Entre em seu ~b~veiculo ~w~para salvar salvar nesta propriedade");
- TextDrawShowForPlayer(playerid, svText[playerid]);
- SetPVarInt(playerid, "CasaDoCarro", player_house_here);
- SetPVarInt(playerid, "SelecionandoCarro", 1);
- }
- }
- case 1:
- {
- TextDrawSetString(svText[playerid], "Voce trancou sua residencia.");
- TextDrawShowForPlayer(playerid, svText[playerid]);
- }
- case 2:{
- if(iHouse[player_house_here][HOUSE_SELL]){
- return SendClientMessage(playerid, -1,"[INFO]: Esta casa já está avenda!");
- }
- static n[24]; GetPlayerName(playerid, n, 24);
- format(string, sizeof(string),"[INFO]: %s colocou está querendo sua residencia, N %i", n, player_house_here);
- SendClientMessageToAll(-1, string);
- iHouse[player_house_here][HOUSE_SELL] = true;
- }
- case 3:{
- ShowPlayerDialog(playerid, DIALOG_EXPPUL, DIALOG_STYLE_INPUT, "~ Residencia: Expulsar jogador ~", "Digite o id do jogador que queiras expulsar", "Expulsar", "Cancelar");
- }
- }
- }
- }
- if(dialogid == DIALOG_EXPPUL){
- if(response){
- static tmp_id;
- tmp_id = strval(inputtext);
- if(!IsPlayerConnected(tmp_id)){
- return SendClientMessage(playerid, -1, "[ERRO]: Este jogador não está online!");
- }
- static tmp_houseid;
- tmp_houseid = GetPVarInt(playerid, "playerenteredhouse");
- if(tmp_houseid != GetPVarInt(tmp_id, "playerenteredhouse")){
- return SendClientMessage(playerid, -1, "[ERRO]: Este jogador não está em sua casa!");
- }
- SetPlayerInterior(tmp_id, 0);
- SetPlayerVirtualWorld(tmp_id, 0);
- SetPlayerPos(tmp_id, iHouse[tmp_houseid][PICKUP_X],iHouse[tmp_houseid][PICKUP_Y],iHouse[tmp_houseid][PICKUP_Z]);
- static n[24];
- GetPlayerName(playerid, n, 24);
- format(string, sizeof(string), "O Jogador %s te expulsou da casa dele.",n ); SendClientMessage(tmp_id, -1, string);
- GetPlayerName(tmp_id, n, 24);
- format(string, sizeof(string), "Você expulsou o %s de sua casa.",n ); SendClientMessage(playerid, -1, string);
- }
- }
- return true;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate){
- if(newstate == PLAYER_STATE_DRIVER){
- if(GetPVarInt(playerid, "SelecionandoCarro") == 1){
- TextDrawSetString(svText[playerid], "Agora, estacione seu veiculo.. digite ~y~/Tunar~n~~w~para tunar seu veiculo Aperte~g~~h~~h~ y ~w~ para salvar.");
- TextDrawShowForPlayer(playerid, svText[playerid]);
- SetPVarInt(playerid, "SelecionandoCarro", 2);
- }
- }
- return true;
- }
- public OnPlayerPickUpDynamicPickup(playerid, pickupid){
- if(pickupid >= iHouse[0][HOUSE_INFOPICKUP] || pickupid <= iHouse[CASAS_CRIADAS - 1][HOUSE_INFOPICKUP]){
- if(GetPVarInt(playerid, "playerenteredhouse") != -1 && GetPlayerInterior(playerid) != 0 && GetPlayerVirtualWorld(playerid) != 0){
- if( (gettime() - GetPVarInt(playerid, "__dialogspam")) > 2 ){
- ShowPlayerDialog(playerid, DIALOG_HOUSEINFO, DIALOG_STYLE_LIST, "~ Residencia ~", "Veiculo pessoal\nTrancar casa\nVender Casa\nExpulsar player de sua casa", "Selecionar", "Fechar");
- SetPVarInt(playerid, "__dialogspam", gettime());
- }
- }
- }
- static houseid;
- for(houseid = 0; houseid != CASAS_CRIADAS; ++houseid)
- {
- if(IsPlayerInRangeOfPoint(playerid, 1.5, iHouse[houseid][PICKUP_X], iHouse[houseid][PICKUP_Y], iHouse[houseid][PICKUP_Z])){
- if( (gettime() - GetPVarInt(playerid, "__housespam")) > 2 ){
- static
- _strhouseshow[200]
- ;
- 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],
- iHouse[houseid][HOUSE_SELL] ? ("Sim") : ("Nao"), iHouse[houseid][HOUSE_CARMODELO]);
- // printf(_strhouseshow);
- TextDrawSetString(iText[playerid], _strhouseshow);
- TextDrawShowForPlayer(playerid, iText[playerid]);
- SetPVarInt(playerid, "__playerinhouse", 1);
- SetTimerEx("@OnPlayerDynamicHouse", 1000, false, "i", playerid);
- SetPVarInt(playerid, "inhouseid", houseid);
- SetPVarInt(playerid, "__housespam", gettime());
- }
- }
- }
- return true;
- }
- OnPlayerLeaveDynamicHouse(playerid, houseid); public OnPlayerLeaveDynamicHouse(playerid, houseid){
- format(string, sizeof(string),"Você saiu da casa: %d", houseid);
- //SendClientMessage(playerid, -1, string);
- SetPVarInt(playerid, "inhouseid", -1);
- TextDrawHideForPlayer(playerid, iText[playerid]);
- return true;
- }
- forward @OnPlayerDynamicHouse(playerid); public @OnPlayerDynamicHouse(playerid){
- if(GetPVarInt(playerid, "__playerinhouse"))
- {
- static per, esta;
- esta = -1;
- for(per = 0; per != CASAS_CRIADAS; ++per){
- if(IsPlayerInRangeOfPoint(playerid, 1.5, iHouse[per][PICKUP_X], iHouse[per][PICKUP_Y], iHouse[per][PICKUP_Z])){
- esta = per;
- break;
- }
- }
- // printf("esta: %d == -1", esta);
- if(esta == -1)
- return CallLocalFunction("OnPlayerLeaveDynamicHouse", "ii", playerid, esta);
- SetTimerEx("@OnPlayerDynamicHouse", 800, false, "i", playerid);
- }
- return true;
- }
- public OnFilterScriptExit(){
- for(new i; i != CASAS_CRIADAS; ++i) Delete3DTextLabel(iHouse[i][HOUSE_TXT]), Delete3DTextLabel(iHouse[i][HOUSE_EXIT]);
- for(new i; i != CASAS_CRIADAS; ++i) DestroyDynamicPickup(iHouse[i][HOUSE_PICKUPS]), DestroyDynamicPickup(iHouse[i][HOUSE_INFOPICKUP]);
- for(new i; i != MAX_PLAYERS; ++i) TextDrawDestroy(iText[i]),TextDrawDestroy(svText[i]),OnPlayerDisconnect(i, 0);
- return false;
- }
- public OnFilterScriptInit(){
- DisableInteriorEnterExits();
- static timer;
- timer = gettime();
- LoadHouses();
- printf("\n\n\nDemorou %d segundos para carregar as casas.\n\n\n", gettime() - timer);
- for(new i; i != MAX_PLAYERS; ++i){
- iText[i] = TextDrawCreate(145.000000, 357.000000, "Casa: 60~n~Preco: 735~n~Dono: Nenhum~n~A Venda: Nao~n~");
- TextDrawBackgroundColor(iText[i], 255);
- TextDrawFont(iText[i], 1);
- TextDrawLetterSize(iText[i], 0.289999, 1.500000);
- TextDrawColor(iText[i], -1);
- TextDrawSetOutline(iText[i], 1);
- TextDrawSetProportional(iText[i], 1);
- TextDrawUseBox(iText[i], 1);
- TextDrawBoxColor(iText[i], 85);
- TextDrawTextSize(iText[i], 260.000000, 0.000000);
- svText[i] = TextDrawCreate(259.000000, 371.000000, "Entre em seu veiculo para salvar nesta propriedade");
- TextDrawBackgroundColor(svText[i], 255);
- TextDrawFont(svText[i], 1);
- TextDrawLetterSize(svText[i], 0.240000, 1.000000);
- TextDrawColor(svText[i], -1);
- TextDrawSetOutline(svText[i], 1);
- TextDrawSetProportional(svText[i], 1);
- }
- return true;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys){
- if(newkeys & KEY_YES)
- {
- if(GetPVarInt(playerid, "SelecionandoCarro") == 2)
- {
- static houseid;
- houseid = GetPVarInt(playerid, "CasaDoCarro");
- if(!IsPlayerInRangeOfPoint(playerid, 25.0, iHouse[houseid][PICKUP_X], iHouse[houseid][PICKUP_Y], iHouse[houseid][PICKUP_Z]))
- {
- TextDrawSetString(svText[playerid], "~r~ERRO:~w~Voce deve estar perto de sua casa!");
- TextDrawShowForPlayer(playerid, svText[playerid]);
- }else
- {
- SetPVarInt(playerid, "SelecionandoCarro", 0);
- SetPVarInt(playerid, "CasaDoCarro", -1);
- TextDrawSetString(svText[playerid], "~g~~h~~h~Pronto ~w~veiculo salvo com sucesso!");
- TextDrawShowForPlayer(playerid, svText[playerid]);
- format(string, sizeof(string), "/casas/%d.reg", houseid);
- static player_vehicle;
- player_vehicle = GetPlayerVehicleID(playerid);
- iHouse[houseid][HOUSE_CARMODELO] = GetVehicleModel(player_vehicle);
- dini_IntSet(string, "Modelo", GetVehicleModel(GetPlayerVehicleID(playerid)));
- iHouse[houseid][HOUSE_CARCOMP][0] = GetVehicleComponentInSlot(player_vehicle, CARMODTYPE_SPOILER);
- iHouse[houseid][HOUSE_CARCOMP][1] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_HOOD);
- iHouse[houseid][HOUSE_CARCOMP][2] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_ROOF);
- iHouse[houseid][HOUSE_CARCOMP][3] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_SIDESKIRT);
- iHouse[houseid][HOUSE_CARCOMP][4] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_LAMPS);
- iHouse[houseid][HOUSE_CARCOMP][5] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_NITRO);
- iHouse[houseid][HOUSE_CARCOMP][6] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_EXHAUST);
- iHouse[houseid][HOUSE_CARCOMP][7] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_WHEELS);
- iHouse[houseid][HOUSE_CARCOMP][8] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_STEREO);
- iHouse[houseid][HOUSE_CARCOMP][9] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_HYDRAULICS);
- iHouse[houseid][HOUSE_CARCOMP][10] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_FRONT_BUMPER);
- iHouse[houseid][HOUSE_CARCOMP][11] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_REAR_BUMPER);
- iHouse[houseid][HOUSE_CARCOMP][12] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_VENT_RIGHT);
- iHouse[houseid][HOUSE_CARCOMP][13] = GetVehicleComponentInSlot(player_vehicle,CARMODTYPE_VENT_LEFT);
- static
- Float: tmp_POS[3],
- tmp_sv_str[15],
- int
- ;
- tmp_sv_str[0] = '\0';
- for(int = 0; int != 13; ++int){
- format(tmp_sv_str, sizeof(tmp_sv_str),"Componente%i", int);
- dini_IntSet(string, tmp_sv_str, iHouse[houseid][HOUSE_CARCOMP][int]);
- }
- GetVehiclePos(player_vehicle, tmp_POS[0], tmp_POS[1],tmp_POS[2]);
- dini_FloatSet(string, "Carro_X", tmp_POS[0]);
- dini_FloatSet(string, "Carro_Y", tmp_POS[1]);
- dini_FloatSet(string, "Carro_Z", tmp_POS[2]);
- iHouse[houseid][CARRO_X] = tmp_POS[0];
- iHouse[houseid][CARRO_Y] = tmp_POS[1];
- iHouse[houseid][CARRO_Z] = tmp_POS[2];
- SetTimerEx("@ClosePlayerText", 1500, false, "i", playerid);
- }
- }
- }
- if(newkeys & KEY_SECONDARY_ATTACK){
- if(GetPVarInt(playerid, "playerenteredhouse") == -1) {
- static houseid;
- houseid = GetPVarInt(playerid, "inhouseid");
- if(houseid != -1){
- static pnome[24];
- GetPlayerName(playerid, pnome, 24);
- if(!strcmp(iHouse[houseid][HOUSE_OWNER], pnome, true)){
- SetPlayerVirtualWorld(playerid, iHouse[houseid][HOUSE_VW]);
- SetPlayerPos(playerid, iHouse[houseid][ENTER_X],iHouse[houseid][ENTER_Y],iHouse[houseid][ENTER_Z]);
- SetPlayerInterior(playerid, iHouse[houseid][HOUSE_INT]);
- SetPVarInt(playerid, "playerenteredhouse", houseid);
- return true;
- }
- }
- }
- if(GetPVarInt(playerid, "playerenteredhouse") != -1){
- static houseid;
- houseid = GetPVarInt(playerid, "playerenteredhouse");
- if(IsPlayerInRangeOfPoint(playerid, 2.0, iHouse[houseid][ENTER_X],iHouse[houseid][ENTER_Y],iHouse[houseid][ENTER_Z]))
- {
- SetPlayerVirtualWorld(playerid, 0);
- SetPlayerPos(playerid, iHouse[houseid][PICKUP_X],iHouse[houseid][PICKUP_Y],iHouse[houseid][PICKUP_Z]);
- SetPlayerInterior(playerid, 0);
- SetPVarInt(playerid, "playerenteredhouse", -1);
- }
- }
- }
- return true;
- }
- forward @ClosePlayerText(playerid); public @ClosePlayerText(playerid){
- TextDrawHideForPlayer(playerid, svText[playerid]);
- return true;
- }
- public OnPlayerDisconnect(playerid, reason){
- SetPVarInt(playerid, "playerenteredhouse", -1);
- SetPVarInt(playerid, "inhouseid", -1);
- return true;
- }
- public OnPlayerConnect(playerid){
- SetPVarInt(playerid, "playerenteredhouse", -1);
- return true;
- }
- CMD:inter(playerid, params[]){
- SetPlayerInterior(playerid, 12);
- SetPlayerPos(playerid, 2324.419921,-1145.568359,1050.710083);
- return true;
- }
- CMD:comprar(playerid, params[]){
- if(GetPVarInt(playerid, "inhouseid") == -1){
- return SendClientMessage(playerid, -1,"[INFO]: Você não está em uma residência!");
- }
- static
- houseid
- ;
- houseid = GetPVarInt(playerid, "inhouseid");
- if(!iHouse[houseid][HOUSE_SELL]){
- return SendClientMessage(playerid, -1,"[INFO]: Esta casa não está à venda");
- }
- if(GetPlayerMoney(playerid) < iHouse[houseid][HOUSE_PRECO]){
- return SendClientMessage(playerid, -1,"[INFO]: Você não tem dinheiro suficiente para comprar esta casa!");
- }
- static
- _tmpstr[128],
- nomej[24]
- ;
- GetPlayerName(playerid, nomej, 24);
- //GivePlayerMoney(playerid, -iHouse[houseid][HOUSE_PRECO]);
- format(_tmpstr, 128,"casas/%d.reg", houseid);
- dini_Set(_tmpstr, "Dono", nomej);
- dini_IntSet(_tmpstr, "Venda", 0);
- iHouse[houseid][HOUSE_SELL] = false;
- format(iHouse[houseid][HOUSE_OWNER], 30, nomej);
- 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]);
- TextDrawSetString(iText[playerid], _tmpstr);
- TextDrawShowForPlayer(playerid, iText[playerid]);
- format(_tmpstr, 128, "Casa id:%i\nDono: %s",houseid, nomej);
- Update3DTextLabelText(iHouse[houseid][HOUSE_TXT], 0x008080FF, _tmpstr);
- format(_tmpstr, 128,"[INFO]: Você comprou a residencia por R$: %d, aperte \"F\" para poder entrar.", iHouse[houseid][HOUSE_PRECO]);
- SendClientMessage(playerid, -1, _tmpstr);
- return true;
- }
- CMD:casa(playerid, params[]){
- static
- preco
- ;
- if(sscanf(params, "i", preco)){
- return SendClientMessage(playerid, -1,"[INFO]: /casa <preco>");
- }
- static
- house_str[60],
- Float: _Pos[3],
- i
- ;
- for(i = 0; i != MAX_HOUSES; ++i){
- format(house_str, 60, "/casas/%d.reg", i);
- if(!fexist(house_str)) break;
- }
- fclose(fopen(house_str, io_write));
- GetPlayerPos(playerid, _Pos[0], _Pos[1], _Pos[2]);
- dini_IntSet(house_str, "Preco", preco);
- dini_FloatSet(house_str, "PickX",_Pos[0]);
- dini_FloatSet(house_str, "PickY",_Pos[1]);
- dini_FloatSet(house_str, "PickZ",_Pos[2]);
- dini_FloatSet(house_str, "EnterX", 235.34);
- dini_FloatSet(house_str, "EnterY", 1186.68); // SetPlayerPos(playerid, 235.34,1186.68,1080.26);
- dini_FloatSet(house_str, "EnterZ", 1080.26);
- dini_FloatSet(house_str, "EnterA", 357.4933);
- dini_IntSet(house_str, "Modelo", 0);
- dini_IntSet(house_str, "HouseLocked", 0);
- dini_IntSet(house_str, "Interior", 3);
- dini_IntSet(house_str, "VirtualWorld", HOUSE_DEFAULT_INT + CASAS_CRIADAS);
- CreateDynamicMapIcon(_Pos[0], _Pos[1], _Pos[2], 0, 0xC0C0C0FF);
- format(string, sizeof(string), "Você criou a casas N %i, X: %f, Y: %f, Z: %f", CASAS_CRIADAS, _Pos[0], _Pos[1], _Pos[2]);
- SendClientMessage(playerid, -1, string);
- CASAS_CRIADAS ++;
- return true;
- }
- stock sscanf(_stsadasstring[], format[], {Float,_}:...)
- {
- #if defined isnull
- if (isnull(_stsadasstring))
- #else
- if (_stsadasstring[0] == 0 || (_stsadasstring[0] == 1 && _stsadasstring[1] == 0))
- #endif
- {
- return format[0];
- }
- #pragma tabsize 4
- new
- formatPos = 0,
- _stsadasstringPos = 0,
- paramPos = 2,
- paramCount = numargs(),
- delim = ' ';
- while (_stsadasstring[_stsadasstringPos] && _stsadasstring[_stsadasstringPos] <= ' ')
- {
- _stsadasstringPos++;
- }
- while (paramPos < paramCount && _stsadasstring[_stsadasstringPos])
- {
- switch (format[formatPos++])
- {
- case '\0':
- {
- return 0;
- }
- case 'i', 'd':
- {
- new
- neg = 1,
- num = 0,
- ch = _stsadasstring[_stsadasstringPos];
- if (ch == '-')
- {
- neg = -1;
- ch = _stsadasstring[++_stsadasstringPos];
- }
- do
- {
- _stsadasstringPos++;
- if ('0' <= ch <= '9')
- {
- num = (num * 10) + (ch - '0');
- }
- else
- {
- return -1;
- }
- }
- while ((ch = _stsadasstring[_stsadasstringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num * neg);
- }
- case 'h', 'x':
- {
- new
- num = 0,
- ch = _stsadasstring[_stsadasstringPos];
- do
- {
- _stsadasstringPos++;
- switch (ch)
- {
- case 'x', 'X':
- {
- num = 0;
- continue;
- }
- case '0' .. '9':
- {
- num = (num << 4) | (ch - '0');
- }
- case 'a' .. 'f':
- {
- num = (num << 4) | (ch - ('a' - 10));
- }
- case 'A' .. 'F':
- {
- num = (num << 4) | (ch - ('A' - 10));
- }
- default:
- {
- return -1;
- }
- }
- }
- while ((ch = _stsadasstring[_stsadasstringPos]) > ' ' && ch != delim);
- setarg(paramPos, 0, num);
- }
- case 'c':
- {
- setarg(paramPos, 0, _stsadasstring[_stsadasstringPos++]);
- }
- case 'f':
- {
- new changestr[16], changepos = 0, strpos = _stsadasstringPos;
- while(changepos < 16 && _stsadasstring[strpos] && _stsadasstring[strpos] != delim)
- {
- changestr[changepos++] = _stsadasstring[strpos++];
- }
- changestr[changepos] = '\0';
- setarg(paramPos,0,_:floatstr(changestr));
- }
- case 'p':
- {
- delim = format[formatPos++];
- continue;
- }
- case '\'':
- {
- new
- end = formatPos - 1,
- ch;
- while ((ch = format[++end]) && ch != '\'') {}
- if (!ch)
- {
- return -1;
- }
- format[end] = '\0';
- if ((ch = strfind(_stsadasstring, format[formatPos], false, _stsadasstringPos)) == -1)
- {
- if (format[end + 1])
- {
- return -1;
- }
- return 0;
- }
- format[end] = '\'';
- _stsadasstringPos = ch + (end - formatPos);
- formatPos = end + 1;
- }
- case 'u':
- {
- new
- end = _stsadasstringPos - 1,
- id = 0,
- bool:num = true,
- ch;
- while ((ch = _stsadasstring[++end]) && ch != delim)
- {
- if (num)
- {
- if ('0' <= ch <= '9')
- {
- id = (id * 10) + (ch - '0');
- }
- else
- {
- num = false;
- }
- }
- }
- if (num && IsPlayerConnected(id))
- {
- setarg(paramPos, 0, id);
- }
- else
- {
- #if !defined foreach
- #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
- #define __SSCANF_FOREACH__
- #endif
- _stsadasstring[end] = '\0';
- num = false;
- new
- name[MAX_PLAYER_NAME];
- id = end - _stsadasstringPos;
- foreach (Player, playerid)
- {
- GetPlayerName(playerid, name, sizeof (name));
- if (!strcmp(name, _stsadasstring[_stsadasstringPos], true, id))
- {
- setarg(paramPos, 0, playerid);
- num = true;
- break;
- }
- }
- if (!num)
- {
- setarg(paramPos, 0, INVALID_PLAYER_ID);
- }
- _stsadasstring[end] = ch;
- #if defined __SSCANF_FOREACH__
- #undef foreach
- #undef __SSCANF_FOREACH__
- #endif
- }
- _stsadasstringPos = end;
- }
- case 's', 'z':
- {
- new
- i = 0,
- ch;
- if (format[formatPos])
- {
- while ((ch = _stsadasstring[_stsadasstringPos++]) && ch != delim)
- {
- setarg(paramPos, i++, ch);
- }
- if (!i)
- {
- return -1;
- }
- }
- else
- {
- while ((ch = _stsadasstring[_stsadasstringPos++]))
- {
- setarg(paramPos, i++, ch);
- }
- }
- _stsadasstringPos--;
- setarg(paramPos, i, '\0');
- }
- default:
- {
- continue;
- }
- }
- while (_stsadasstring[_stsadasstringPos] && _stsadasstring[_stsadasstringPos] != delim && _stsadasstring[_stsadasstringPos] > ' ')
- {
- _stsadasstringPos++;
- }
- while (_stsadasstring[_stsadasstringPos] && (_stsadasstring[_stsadasstringPos] == delim || _stsadasstring[_stsadasstringPos] <= ' '))
- {
- _stsadasstringPos++;
- }
- paramPos++;
- }
- do
- {
- if ((delim = format[formatPos++]) > ' ')
- {
- if (delim == '\'')
- {
- while ((delim = format[formatPos++]) && delim != '\'') {}
- }
- else if (delim != 'z')
- {
- return delim;
- }
- }
- }
- while (delim > ' ');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement