Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //======================================[ INCLUDES ]====================================||
- #include <a_samp>
- #include <sscanf2>
- #include <streamer>
- #include <a_mysql>
- #include <Pawn.CMD>
- #include <YSI\y_iterate>
- //======================================[ DEFINES ]====================================||
- #define MAX_HOUSES (64)
- #define COR_ERRO 0xFF0000AA
- #define COR_AMARELO 0xFFFF00AA
- #define HOST "localhost"
- #define USER "root"
- #define PASS ""
- #define DTBS "samp"
- //======================================[ ENUMS ]====================================||
- enum HouseInfos{
- cID,
- cProprietario[MAX_PLAYER_NAME],
- cValor,
- cInterior,
- cVirtualWorld,
- cComprado,
- cLevel,
- cLevelMax,
- Text3D:cText,
- cMapIcon,
- cPickUp,
- Float:cPosX,
- Float:cPosY,
- Float:cPosZ,
- Float:InteriorX,
- Float:InteriorY,
- Float:InteriorZ,
- Float:InteriorA
- }
- //======================================[ FILTERSCRIPT ]====================================||
- new Iterator:HouseIterator<MAX_HOUSES>;
- static Casas[MAX_HOUSES][HouseInfos];
- new MySQL: ConexaoID;
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" iCasas v0.1 - - - - - - - - By: Cauezin");
- print("--------------------------------------\n");
- ConectarDB();
- DisableInteriorEnterExits();
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- stock GetPlayerNameEx(playerid)
- {
- static Name[MAX_PLAYER_NAME];
- GetPlayerName(playerid, Name, sizeof(Name));
- return Name;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- new string[64];
- new Float: Ang;
- if(newkeys == KEY_SECONDARY_ATTACK)
- {
- new id = GetPlayerNearestHouse(playerid);
- if(id > -1)
- {
- SetPlayerPos(playerid, Casas[id][InteriorX], Casas[id][InteriorY], Casas[id][InteriorZ]);
- SetPlayerFacingAngle(playerid, Casas[id][InteriorA]);
- SetPlayerVirtualWorld(playerid, Casas[id][cID]);
- SetPlayerInterior(playerid, Casas[id][cInterior]);
- format(string, sizeof(string), "[iCasas] Você entrou na casa [ %d ]", Casas[id][cID]);
- SendClientMessage(playerid, COR_AMARELO, string);
- }
- }
- if(newkeys == KEY_SECONDARY_ATTACK)
- {
- new id = GetPlayerNearestExitHouse(playerid);
- if(id > -1)
- {
- SetPlayerPos(playerid, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ]);
- SetPlayerFacingAngle(playerid, GetPlayerFacingAngle(playerid, Ang));
- SetPlayerVirtualWorld(playerid, 0);
- SetPlayerInterior(playerid,0);
- SendClientMessage(playerid, COR_AMARELO, "[iCasas] Você saiu dessa casa.");
- }
- }
- return 1;
- }
- stock ConectarDB()
- {
- ConexaoID = mysql_connect(HOST, USER, PASS, DTBS);
- if(ConexaoID == MYSQL_INVALID_HANDLE || mysql_errno(ConexaoID) != 0)
- {
- print("[MYSQL] Conexão falhou.");
- }else{
- print("[MYSQL] Conexão bem sucedida");
- CarregarCasasInfo();
- }
- }
- forward CarregarCasasInfo();
- public CarregarCasasInfo()
- {
- new Cache:cache = mysql_query(ConexaoID, "SELECT * FROM `Casas`", true);
- if(cache_num_rows())
- {
- for(new i=0, rows = cache_num_rows(); i < rows; i++)
- {
- cache_get_value_name_int(i, "cID", Casas[i][cID]);
- cache_get_value_name(i, "cProprietario", Casas[i][cProprietario], MAX_PLAYER_NAME);
- cache_get_value_name_int(i, "cValor", Casas[i][cValor]);
- cache_get_value_name_int(i, "cInterior", Casas[i][cInterior]);
- cache_get_value_name_int(i, "cVirtualWorld", Casas[i][cID]);
- cache_get_value_name_int(i, "cComprado", Casas[i][cComprado]);
- cache_get_value_name_int(i, "cLevel", Casas[i][cLevel]);
- cache_get_value_name_int(i, "cLevelMax", Casas[i][cLevelMax]);
- cache_get_value_name_float(i, "cPosX", Casas[i][cPosX]);
- cache_get_value_name_float(i, "cPosY", Casas[i][cPosY]);
- cache_get_value_name_float(i, "cPosZ", Casas[i][cPosZ]);
- cache_get_value_name_float(i, "InteriorX", Casas[i][InteriorX]);
- cache_get_value_name_float(i, "InteriorY", Casas[i][InteriorY]);
- cache_get_value_name_float(i, "InteriorZ", Casas[i][InteriorZ]);
- cache_get_value_name_float(i, "InteriorA", Casas[i][InteriorA]);
- UpdateHouse(i);
- Iter_Add(HouseIterator, i);
- }
- }
- cache_delete(cache);
- return 1;
- }
- stock UpdateHouse(id)
- {
- new string[350];
- if(Casas[id][cComprado] == 0)
- {
- format(string, sizeof(string), "ID: {FFFF33}%d{FFFFFF}\nLevel: {FFFF33}%d{FFFFFF}|{FFFF33}%d\n\n{FFFFFF}Proprietario: {FFFF33}N/A.{FFFFFF}\nValor: {FFFF33}%dR${FFFFFF}.\nUse {FFFF33}/comprarcasa {FFFFFF}para comprar.", Casas[id][cID], Casas[id][cLevel], Casas[id][cLevelMax],Casas[id][cValor]);
- Casas[id][cText] = CreateDynamic3DTextLabel(string, -1, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, 0, 0);
- Casas[id][cPickUp] = CreateDynamicPickup((Casas[id][cComprado] != 0) ? (19522) : (1273), 23, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], 0, 0);
- Casas[id][cMapIcon] = CreateDynamicMapIcon(Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], (Casas[id][cComprado] != 0) ? (32) : (31), 0, 0, 0);
- }else{
- format(string, sizeof(string), "ID: {FFFF33}%d{FFFFFF}\nLevel: {FFFF33}%d{FFFFFF}|{FFFF33}%d\n\nProprietario: {FFFF33}%s\nPressione {FFFF33}F{FFFFFF} para entrar na casa.", Casas[id][cID], Casas[id][cLevel], Casas[id][cLevelMax], Casas[id][cProprietario]);
- Casas[id][cText] = CreateDynamic3DTextLabel(string, -1, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, 0, 0);
- Casas[id][cPickUp] = CreateDynamicPickup((Casas[id][cComprado] != 0) ? (19522) : (1273), 23, Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], 0, 0);
- Casas[id][cMapIcon] = CreateDynamicMapIcon(Casas[id][cPosX], Casas[id][cPosY], Casas[id][cPosZ], (Casas[id][cComprado] != 0) ? (32) : (31), 0, 0, 0);
- }
- return 1;
- }
- CreateHouse(price, levelmax ,Float:x, Float:y, Float:z ,Float: intx ,Float: inty , Float:intz, Float:inta)
- {
- new id = Iter_Free(HouseIterator);
- if (id == cellmin)
- return -1;
- Casas[id][cProprietario][0] = EOS;
- Casas[id][cComprado] = 0;
- Casas[id][cValor] = price;
- Casas[id][cLevel] = 0;
- Casas[id][cLevelMax] = levelmax;
- Casas[id][cPosX] = x;
- Casas[id][cPosY] = y;
- Casas[id][cPosZ] = z;
- Casas[id][InteriorX] = intx;
- Casas[id][InteriorY] = inty;
- Casas[id][InteriorZ] = intz;
- Casas[id][InteriorA] = inta;
- switch(Casas[id][cLevel])
- {
- case 0:
- {
- Casas[id][InteriorX] = 2233.69;
- Casas[id][InteriorY] = -1115.26;
- Casas[id][InteriorZ] = 1050.88;
- Casas[id][InteriorA] = 358.4660;
- Casas[id][cInterior] = 5;
- }
- }
- new query[300];
- mysql_format(ConexaoID, query, sizeof(query), "INSERT INTO `Casas` ( `cValor`, `cPosX`, `cPosY`, `cPosZ`, `cComprado` , `cInterior` , `InteriorX` , `InteriorY` , `InteriorZ` , `InteriorA`, `cLevelMax` , `cLevel` ) VALUES ( %i , %f , %f , %f, %i , %i , %f , %f , %f , %f , %i , %i )",
- Casas[id][cValor],
- Casas[id][cPosX],
- Casas[id][cPosY],
- Casas[id][cPosZ],
- Casas[id][cComprado],
- Casas[id][cInterior],
- Casas[id][InteriorX],
- Casas[id][InteriorY],
- Casas[id][InteriorZ],
- Casas[id][InteriorA],
- Casas[id][cLevelMax],
- Casas[id][cLevel]);
- mysql_tquery(ConexaoID, query, "OnInsertHouse", "i", id);
- Iter_Add(HouseIterator, id);
- return id;
- }
- forward OnInsertHouse(id);
- public OnInsertHouse(id)
- {
- new index = cache_insert_id();
- Casas[id][cID] = index;
- Casas[id][cVirtualWorld] = index;
- UpdateHouse(id);
- printf("[iCasas]Casa ID %i | %i inserida com sucesso na database.", index, Casas[id][cVirtualWorld]);
- }
- PlayerHaveHouse(playerid)
- {
- for (new i = 0; i < MAX_HOUSES; i ++)
- {
- if (!Casas[i][cComprado])
- continue;
- if (!strcmp(Casas[i][cProprietario], GetPlayerNameEx(playerid)))
- return 1;
- }
- return 0;
- }
- GetPlayerNearestHouse(playerid, Float:range = 2.5)
- {
- foreach (new i : HouseIterator)
- {
- if (IsPlayerInRangeOfPoint(playerid, range, Casas[i][cPosX], Casas[i][cPosY], Casas[i][cPosZ]))
- return i;
- }
- return -1;
- }
- GetPlayerNearestExitHouse(playerid, Float:range = 2.5)
- {
- foreach (new i : HouseIterator)
- {
- if (IsPlayerInRangeOfPoint(playerid, range, Casas[i][InteriorX], Casas[i][InteriorY], Casas[i][InteriorZ]) && GetPlayerVirtualWorld(playerid) == Casas[i][cID])
- return i;
- }
- return -1;
- }
- CMD:criarcasa(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid))
- return 0;
- new Float:x, Float:y, Float:z ,Float: intx,Float: inty, Float:intz, Float:inta , levelmax, price;
- new string [100];
- GetPlayerPos(playerid, x, y, z);
- new id;
- if(sscanf(params, "ii", price, levelmax))
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Digite /criarcasa [valor] [levelmax 0-10]"), 0;
- if(levelmax > 10 || levelmax < 0)
- return SendClientMessage(id, COR_ERRO, "[iCasas] Digite /criarcasa [valor] {6300af}[levelmax *0-10*]"), 0;
- id = CreateHouse(price, levelmax, x, y, z, intx, inty, intz, inta);
- if (id == -1)
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Limite de casas atingido.");
- SendClientMessage(playerid, COR_AMARELO, "[iCasas] Casa criada com sucesso. ");
- format(string, sizeof(string), "[iCasas] Valor: $%d | LevelMax: [ %d ]", price, levelmax);
- SendClientMessage(playerid, COR_AMARELO, string);
- return 1;
- }
- CMD:editarcasa(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid))
- return 0;
- new id = GetPlayerNearestHouse(playerid);
- new query[250], levelmax, level;
- new str[120];
- if (id == -1)
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não está em um ícone de uma casa");
- if(sscanf(params, "iii", Casas[id][cValor], Casas[id][cLevel] ,levelmax))
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Digite /editarcasa [valor] [level *0-10*] [LevelMax 0-10]");
- if(levelmax > 10 || levelmax < 0 || level > levelmax || level < 0)
- return SendClientMessage(id, COR_ERRO, "[iCasas] Digite /criarcasa [valor] {6300af}[level *0-10*] [LevelMax *0-10*]");
- switch(Casas[id][cLevel])
- {
- case 0:
- {
- Casas[id][InteriorX] = 2233.69;
- Casas[id][InteriorY] = -1115.26;
- Casas[id][InteriorZ] = 1050.88;
- Casas[id][InteriorA] = 358.4660;
- Casas[id][cInterior] = 5;
- }
- case 1:
- {
- Casas[id][InteriorX] = 2282.99;
- Casas[id][InteriorY] = -1140.28;
- Casas[id][InteriorZ] = 1050.89;
- Casas[id][InteriorA] = 358.4660;
- Casas[id][cInterior] = 11;
- }
- case 2:
- {
- Casas[id][InteriorX] = 2259.38;
- Casas[id][InteriorY] = -1135.89;
- Casas[id][InteriorZ] = 1050.64;
- Casas[id][InteriorA] = 275.3992;
- Casas[id][cInterior] = 10;
- }
- case 3:
- {
- Casas[id][InteriorX] = 2218.39;
- Casas[id][InteriorY] = -1076.21;
- Casas[id][InteriorZ] = 1050.48;
- Casas[id][InteriorA] = 95.2635;
- Casas[id][cInterior] = 1;
- }
- case 4:
- {
- Casas[id][InteriorX] = 2196.84;
- Casas[id][InteriorY] = -1204.36;
- Casas[id][InteriorZ] = 1049.02;
- Casas[id][InteriorA] = 94.0010;
- Casas[id][cInterior] = 6;
- }
- case 5:
- {
- Casas[id][InteriorX] = 2365.25;
- Casas[id][InteriorY] = -1135.58;
- Casas[id][InteriorZ] = 1050.88;
- Casas[id][InteriorA] = 359.0367;
- Casas[id][cInterior] = 8;
- }
- case 6:
- {
- Casas[id][InteriorX] = 2496.00;
- Casas[id][InteriorY] = -1692.08;
- Casas[id][InteriorZ] = 1014.74;
- Casas[id][InteriorA] = 177.8159;
- Casas[id][cInterior] = 3;
- }
- case 7:
- {
- Casas[id][InteriorX] = 140.28;
- Casas[id][InteriorY] = 1365.92;
- Casas[id][InteriorZ] = 1083.85;
- Casas[id][InteriorA] = 9.6901;
- Casas[id][cInterior] = 5;
- }
- case 8:
- {
- Casas[id][InteriorX] = 2317.77;
- Casas[id][InteriorY] = -1026.76;
- Casas[id][InteriorZ] = 1050.21;
- Casas[id][InteriorA] = 359.0367;
- Casas[id][cInterior] = 9;
- }
- case 9:
- {
- Casas[id][InteriorX] = 2324.41;
- Casas[id][InteriorY] = -1149.54;
- Casas[id][InteriorZ] = 1050.71;
- Casas[id][InteriorA] = 359.0367;
- Casas[id][cInterior] = 12;
- }
- case 10:
- {
- Casas[id][InteriorX] = 1260.6603;
- Casas[id][InteriorY] = -785.4005;
- Casas[id][InteriorZ] = 1091.9063;
- Casas[id][InteriorA] = 270.9891;
- Casas[id][cInterior] = 5;
- }
- }
- mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cValor`='%i' , `cInterior`='%i' , `InteriorX`='%f' , `InteriorY`='%f' , `InteriorZ`='%f' , `InteriorA`='%f', `cLevel`='%i' , `cLevelMax`='%i' WHERE `cID`='%i' ",
- Casas[id][cValor],
- Casas[id][cInterior],
- Casas[id][InteriorX],
- Casas[id][InteriorY],
- Casas[id][InteriorZ],
- Casas[id][InteriorA],
- Casas[id][cLevel],
- levelmax,
- Casas[id][cID]);
- mysql_query(ConexaoID, query);
- format(str, sizeof(str), "[iCasas] Você atualizou a casa [ %d ]", Casas[id][cID]);
- SendClientMessage(playerid, COR_AMARELO, str);
- format(str, sizeof(str), "[iCasas] Novo Valor: $%d", Casas[id][cValor]);
- SendClientMessage(playerid, COR_AMARELO, str);
- format(str, sizeof(str), "[iCasas] Novo Level: [ %d ]", Casas[id][cLevel]);
- SendClientMessage(playerid, COR_AMARELO, str);
- format(str, sizeof(str), "[iCasas] Novo LevelMax: [ %d ]", levelmax);
- SendClientMessage(playerid, COR_AMARELO, str);
- DestroyDynamicMapIcon(Casas[id][cMapIcon]);
- DestroyDynamicPickup(Casas[id][cPickUp]);
- DestroyDynamic3DTextLabel(Casas[id][cText]);
- UpdateHouse(id);
- return 1;
- }
- CMD:atualizarcasa(playerid)
- {
- new id = GetPlayerNearestHouse(playerid);
- new query[350];
- new precoup;
- if(id == -1)
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não está no ícone de uma casa.");
- if(Casas[id][cLevel] == Casas[id][cLevelMax])
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Sua casa já está no level máximo.");
- if(!PlayerHaveHouse(playerid))
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Essa não é sua casa");
- switch(Casas[id][cLevel])
- {
- case 0:
- {
- precoup = 1500;
- }
- case 1:
- {
- precoup = 2000;
- }
- case 2:
- {
- precoup = 2750;
- }
- case 3:
- {
- precoup = 3850;
- }
- case 4:
- {
- precoup = 4500;
- }
- case 5:
- {
- precoup = 8500;
- }
- case 6:
- {
- precoup = 16500;
- }
- case 7:
- {
- precoup = 25000;
- }
- case 8:
- {
- precoup = 35000;
- }
- case 9:
- {
- precoup = 1000000;
- }
- }
- if(GetPlayerMoney(playerid) < precoup)
- {
- format(query, sizeof(query), "[iCasas] Você não tem {00ff04}$%d {FFFF00}para atualizar sua casa.", precoup);
- SendClientMessage(playerid, COR_ERRO, query);
- return 0;
- }
- Casas[id][cLevel]++;
- switch(Casas[id][cLevel])
- {
- case 0:
- {
- Casas[id][InteriorX] = 2233.69;
- Casas[id][InteriorY] = -1115.26;
- Casas[id][InteriorZ] = 1050.88;
- Casas[id][InteriorA] = 358.4660;
- Casas[id][cInterior] = 5;
- }
- case 1:
- {
- Casas[id][InteriorX] = 2282.99;
- Casas[id][InteriorY] = -1140.28;
- Casas[id][InteriorZ] = 1050.89;
- Casas[id][InteriorA] = 358.4660;
- Casas[id][cInterior] = 11;
- }
- case 2:
- {
- Casas[id][InteriorX] = 2259.38;
- Casas[id][InteriorY] = -1135.89;
- Casas[id][InteriorZ] = 1050.64;
- Casas[id][InteriorA] = 275.3992;
- Casas[id][cInterior] = 10;
- }
- case 3:
- {
- Casas[id][InteriorX] = 2218.39;
- Casas[id][InteriorY] = -1076.21;
- Casas[id][InteriorZ] = 1050.48;
- Casas[id][InteriorA] = 95.2635;
- Casas[id][cInterior] = 1;
- }
- case 4:
- {
- Casas[id][InteriorX] = 2196.84;
- Casas[id][InteriorY] = -1204.36;
- Casas[id][InteriorZ] = 1049.02;
- Casas[id][InteriorA] = 94.0010;
- Casas[id][cInterior] = 6;
- }
- case 5:
- {
- Casas[id][InteriorX] = 2365.25;
- Casas[id][InteriorY] = -1135.58;
- Casas[id][InteriorZ] = 1050.88;
- Casas[id][InteriorA] = 359.0367;
- Casas[id][cInterior] = 8;
- }
- case 6:
- {
- Casas[id][InteriorX] = 2496.00;
- Casas[id][InteriorY] = -1692.08;
- Casas[id][InteriorZ] = 1014.74;
- Casas[id][InteriorA] = 177.8159;
- Casas[id][cInterior] = 3;
- }
- case 7:
- {
- Casas[id][InteriorX] = 140.28;
- Casas[id][InteriorY] = 1365.92;
- Casas[id][InteriorZ] = 1083.85;
- Casas[id][InteriorA] = 9.6901;
- Casas[id][cInterior] = 5;
- }
- case 8:
- {
- Casas[id][InteriorX] = 2317.77;
- Casas[id][InteriorY] = -1026.76;
- Casas[id][InteriorZ] = 1050.21;
- Casas[id][InteriorA] = 359.0367;
- Casas[id][cInterior] = 9;
- }
- case 9:
- {
- Casas[id][InteriorX] = 2324.41;
- Casas[id][InteriorY] = -1149.54;
- Casas[id][InteriorZ] = 1050.71;
- Casas[id][InteriorA] = 359.0367;
- Casas[id][cInterior] = 12;
- }
- case 10:
- {
- Casas[id][InteriorX] = 1260.6603;
- Casas[id][InteriorY] = -785.4005;
- Casas[id][InteriorZ] = 1091.9063;
- Casas[id][InteriorA] = 270.9891;
- Casas[id][cInterior] = 5;
- }
- }
- mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cLevel`='%i' , `InteriorX`='%f' , `InteriorY`='%f', `InteriorZ`='%f', `InteriorA`='%f' WHERE `cID`='%i' ",
- Casas[id][cLevel],
- Casas[id][InteriorX],
- Casas[id][InteriorY],
- Casas[id][InteriorZ],
- Casas[id][InteriorA],
- Casas[id][cID]);
- mysql_query(ConexaoID, query);
- DestroyDynamicMapIcon(Casas[id][cMapIcon]);
- DestroyDynamicPickup(Casas[id][cPickUp]);
- DestroyDynamic3DTextLabel(Casas[id][cText]);
- UpdateHouse(id);
- GivePlayerMoney(playerid, -precoup);
- format(query, sizeof(query), "[iCasas] Você atualizou sua cara para o nível [ %d ]", Casas[id][cLevel]);
- SendClientMessage(playerid, COR_AMARELO, query);
- format(query, sizeof(query), "[iCasas] {FFFF00}-$%d", precoup);
- SendClientMessage(playerid, COR_AMARELO, query);
- return 1;
- }
- CMD:comprarcasa(playerid, params[])
- {
- new id = GetPlayerNearestHouse(playerid);
- if (id == -1)
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não está em um ícone de uma casa.");
- if(Casas[id][cComprado] == 1)
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Essa casa já possui um dono.");
- if(PlayerHaveHouse(playerid))
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você já tem uma casa.");
- if(GetPlayerMoney(playerid) < Casas[id][cValor])
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não tem dinheiro suficiente.");
- GivePlayerMoney(playerid, -Casas[id][cValor]);
- DestroyDynamicMapIcon(Casas[id][cMapIcon]);
- DestroyDynamicPickup(Casas[id][cPickUp]);
- DestroyDynamic3DTextLabel(Casas[id][cText]);
- Casas[id][cComprado] = 1;
- Casas[id][cProprietario] = EOS;
- strcat(Casas[id][cProprietario], GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
- new query[140];
- new string[60];
- mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cProprietario`='%e', `cComprado`='%i', `cVirtualWorld`='%i' , `cLevel`='0' WHERE `cID`='%i' ", Casas[id][cProprietario], Casas[id][cComprado], Casas[id][cID], Casas[id][cID]);
- mysql_query(ConexaoID, query);
- format(string, sizeof(string), "[iCasas] O(A) %s comprou a casa ID %d.", Casas[id][cProprietario], Casas[id][cID]);
- SendClientMessageToAll(COR_AMARELO, string);
- UpdateHouse(id);
- return 1;
- }
- CMD:vendercasa(playerid)
- {
- new id = GetPlayerNearestHouse(playerid);
- new Name[MAX_HOUSES];
- Name[id] = EOS;
- strcat(Name[id], GetPlayerNameEx(playerid), MAX_PLAYER_NAME);
- if (id == -1)
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não está em um ícone de uma casa.");
- if(Casas[id][cComprado] == 0)
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Essa casa não possui um dono.");
- if(Casas[id][cProprietario] != Name[id])
- return SendClientMessage(playerid, COR_ERRO, "[iCasas] Você não é dono dessa casa.");
- DestroyDynamicMapIcon(Casas[id][cMapIcon]);
- DestroyDynamicPickup(Casas[id][cPickUp]);
- DestroyDynamic3DTextLabel(Casas[id][cText]);
- Casas[id][cLevel] = 0;
- switch(Casas[id][cLevel])
- {
- case 0:
- {
- Casas[id][InteriorX] = 2233.69;
- Casas[id][InteriorY] = -1115.26;
- Casas[id][InteriorZ] = 1050.88;
- Casas[id][InteriorA] = 358.4660;
- Casas[id][cInterior] = 5;
- }
- }
- new string[128];
- new query[250];
- GivePlayerMoney(playerid, Casas[id][cValor] * 75 / 100);
- format(string, sizeof(string), "[iCasas] O(A) %s[%d] vendeu a sua casa ID[ %d ].", Casas[id][cProprietario], playerid,Casas[id][cID]);
- SendClientMessageToAll(COR_AMARELO, string);
- Casas[id][cComprado] = 0;
- mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cProprietario`=NULL , `cComprado`='0', `cLevel`='%i' , `InteriorX`='%f' , `InteriorY`='%f' , `InteriorZ`='%f' , `InteriorA`='%f' , `cInterior`='%i' WHERE `cID`='%i' ",
- Casas[id][cLevel],
- Casas[id][InteriorX],
- Casas[id][InteriorY],
- Casas[id][InteriorZ],
- Casas[id][InteriorA],
- Casas[id][cInterior],
- Casas[id][cID]);
- mysql_query(ConexaoID, query);
- UpdateHouse(id);
- return 1;
- }
- CMD:excluircasa(playerid)
- {
- if(!IsPlayerAdmin(playerid))
- return 0;
- new id = GetPlayerNearestHouse(playerid);
- new query[200];
- if(id == -1)
- return SendClientMessage(playerid, COR_ERRO, "[iCasa] Você não está no ícone de uma casa");
- mysql_format(ConexaoID, query, sizeof(query), "UPDATE `Casas` SET `cProprietario`=NULL , `cComprado`='0' WHERE `cID`='%i' ", Casas[id][cID]);
- mysql_query(ConexaoID, query);
- mysql_format(ConexaoID, query, sizeof(query), "DELETE FROM `Casas` WHERE `cID`='%d'", Casas[id][cID]);
- mysql_query(ConexaoID, query);
- format(query, sizeof(query), "[iCasas] Você excluiu a casa [%d]", Casas[id][cID]);
- SendClientMessage(playerid, COR_AMARELO, query);
- DestroyDynamicMapIcon(Casas[id][cMapIcon]);
- DestroyDynamicPickup(Casas[id][cPickUp]);
- DestroyDynamic3DTextLabel(Casas[id][cText]);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment