How to FIX THIS ?
#4

@Misiur ...ok here is the property FS by Sandra
Quote:

#include <a_samp>
#include <dini>

#define MAX_PROPERTIES 100
#define MAX_PROPERTIES_PER_PLAYER 3
#define UNBUYABLETIME 120 //If a propertie is bought, someone else have to wait this number of minutes before he/she can buy it.

#define ENABLE_LOGIN_SYSTEM 0
#define ENABLE_MAP_ICON_STREAMER 0
#define UsePropertyTextDraw 1

#define REGISTER_COMMAND "/register"
#define LOGIN_COMMAND "/login"

new PropertiesAmount;
new MP;
enum propinfo
{
PropName[64],
Float:PropX,
Float:PropY,
Float:PropZ,
PropIsBought,
PropUnbuyableTime,
PropOwner[MAX_PLAYER_NAME],
PropValue,
PropEarning,
PickupNr,
}
new PropInfo[MAX_PROPERTIES][propinfo]; //CarInfo
new PlayerProps[MAX_PLAYERS];
new EarningsForPlayer[MAX_PLAYERS];
new Logged[MAX_PLAYERS];

public OnFilterScriptInit()
{
LoadProperties();
MP = GetMaxPlayers();
for(new i; i<MP; i++)
{
if(IsPlayerConnected(i))
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, MAX_PLAYER_NAME);
for(new propid; propid < PropertiesAmount; propid++)
{
if(PropInfo[propid][PropIsBought] == 1)
{
if(strcmp(PropInfo[propid][PropOwner], pName, true)==0)
{
EarningsForPlayer[i] += PropInfo[propid][PropEarning];
PlayerProps[i]++;
}
}
}
}
}
SetTimer("UpdateUnbuyableTime", 60000, 1);
#if ENABLE_MAP_ICON_STREAMER == 1
SetTimer("MapIconStreamer", 500, 1);
#endif
SetTimer("PropertyPayout", 60000, 1);
print("-------------------------------------------------");
print("Property-System by =>Sandra<= Succesfully loaded!");
print("-------------------------------------------------");
return 1;
}
public OnFilterScriptExit()
{
print("Properties Saved!!");
return 1;
}

public OnPlayerConnect(playerid)
{
PlayerProps[playerid] = 0;
Logged[playerid] = 0;
EarningsForPlayer[playerid] = 0;
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
for(new propid; propid < PropertiesAmount; propid++)
{
if(PropInfo[propid][PropIsBought] == 1)
{
if(strcmp(PropInfo[propid][PropOwner], pName, true)==0)
{
EarningsForPlayer[playerid] += PropInfo[propid][PropEarning];
PlayerProps[playerid]++;
}
}
}
#if ENABLE_LOGIN_SYSTEM == 1
if(PlayerProps[playerid] > 0)
{
new str[128];
format(str, 128, "You currently own %d properties. Type /myproperties for more info about them.", PlayerProps[playerid]);
SendClientMessage(playerid, 0x99FF66AA, str);
}
#endif
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}
public OnGameModeInit()
{
Create3DTextLabel("Royal Casino\nCost:8000\nEarning:750\n/prophelp",0x008080FF,2088.62,1449.17,10.52,50,0,0) ;
Create3DTextLabel("Four Dragons Casino\nCost:6500\nEarning:900\n/prophelp",0x008080FF,2024.56,1007.65,10.81,50,0,0) ;
Create3DTextLabel("Come A Lot\nCost:6000\nEarning:800\n/prophelp",0x008080FF,2182.12,1115.15,12.35,50,0,0) ;
Create3DTextLabel("Camels Toe\nCost:8000\nEarning:950\n/prophelp",0x008080FF,2208.27,1286.29,10.81,50,0,0) ;
Create3DTextLabel("The High Roller\nCost:6500\nEarning:750\n/prophelp",0x008080FF,1956.68,1342.80,15.35,50,0,0) ;
Create3DTextLabel("Caligula's Casino\nCost:7500\nEarning:800\n/prophelp",0x008080FF,2184.11,1676.77,10.81,50,0,0) ;
Create3DTextLabel("Clowns Pocket\nCost:5000\nEarning:550\n/prophelp",0x008080FF,2220.12,1837.81,10.52,50,0,0) ;
Create3DTextLabel("The Visage\nCost:10000\nEarning:1200\n/prophelp",0x008080FF,2027.27,1914.67,11.93,50,0,0) ;
Create3DTextLabel("Las Venturas Casino\nCost:7500\nEarning:850\n/prophelp",0x008080FF,2165.10,2162.12,10.43,50,0,0) ;
Create3DTextLabel("Well Stacked Pizza\nCost:2500\nEarning:350\n/prophelp",0x008080FF,370.98,-122.94,1001.46,50,0,0);
Create3DTextLabel("ZIP\nCost:2500\nEarning:350\n/prophelp",0x008080FF,161.41,-85.79,1001.78,50,0,0);
Create3DTextLabel("Cluckin Bell\nCost:3500\nEarning:250\n/prophelp",0x008080FF,372.17,-7.71,1001.84,50,0,0);
Create3DTextLabel("Binco\nCost:3500\nEarning:200\n/prophelp",0x008080FF,207.75,-103.05,1005.25,50,0,0);
Create3DTextLabel("Las Venturas Motel\nCost:8000\nEarning:650\n/prophelp",0x008080FF,2084.00,2176.86,10.81,50,0,0) ;
Create3DTextLabel("Tattoo Shop\nCost:3000\nEarning:250\n/prophelp",0x008080FF,-203.13,-42.06,1002.27,50,0,0);
Create3DTextLabel("Barbershop\nCost:3500\nEarning: 200\n/prophelp",0x008080FF,418.95,-78.80,1001.78,50,0,0);
Create3DTextLabel("Las Venturas Sexshop\nCost:4500\nEarning:400\n/prophelp",0x008080FF,2087.2793,2077.0647,11.0579,5 0,0,0);
Create3DTextLabel("Burger Shot\nCost:3500\nEarning:350\n/prophelp",0x008080FF,370.25,-73.25,1001.50,50,0,0);
Create3DTextLabel("Las Venturas Steak House\nCost:4500\nEarning:400\n/prophelp",0x008080FF,1694.01,2206.62,11.06,50,0,0) ;
Create3DTextLabel("Redsands Gasstation\nCost:4000\nEarning:350\n/prophelp",0x008080FF,1600.56,2220.37,11.06,50,0,0) ;
Create3DTextLabel("Las Venturas Airport\nCost:12000\nEarning:1500\n/prophelp",0x008080FF,1675.06,1448.06,10.77,50,0,0) ;
Create3DTextLabel("Los Santos Disco\nCost:3000\nEarning:450\n/prophelp",0x008080FF,1833.43,-1685.06,13.47,50,0,0);
Create3DTextLabel("SkatePark\nCost:4500\nEarning:5 00\n/prophelp",0x008080FF,1881.16,-1399.26,13.27,50,0,0);
Create3DTextLabel("San Andreas Bank\nCost:15000\nEarning:1600\n/prophelp",0x008080FF,1573.68,-1337.43,16.45,50,0,0);
Create3DTextLabel("San Andreas Insurance Company\nCost:9500\nEarning:1150\n/prophelp",0x008080FF,1502.68,-1278.76,14.56,50,0,0);
Create3DTextLabel("Los Santos Hospital\nCost:6500\nEarning:700\n/prophelp",0x008080FF,1177.78,-1323.01,14.06,50,0,0);
Create3DTextLabel("Donutshop\nCost:3500\nEarning:3 50\n/prophelp",0x008080FF,1037.93,-1338.06,13.72,50,0,0);
Create3DTextLabel("The Movie Studio's\nCost:5550\nEarning:650\n/prophelp",0x008080FF,898.90,-1219.81,16.70,50,0,0);
Create3DTextLabel("The Gravejard\nCost:4500\nEarning:350\n/prophelp",0x008080FF,935.82,-1103.17,24.04,50,0,0);
Create3DTextLabel("Comedy Club\nCost:2500\nEarning:150\n/prophelp",0x008080FF,1058.81,-943.88,42.65,50,0,0);
Create3DTextLabel("TennisClub\nCost:3500\nEarning: 250\n/prophelp",0x008080FF,665.21,-1276.93,13.18,50,0,0);
Create3DTextLabel("Vinyl Countdown\nCost:3500\nEarning:250\n/prophelp",0x008080FF,816.03,-1387.68,13.31,50,0,0);
Create3DTextLabel("Prolaps\nCost:2900\nEarning:350 \n/prophelp",0x008080FF,210.52,-129.94,1003.51,50,0,0);
Create3DTextLabel("Mainstreet\nCost:8500\nEarning: 950\n/prophelp",0x008080FF,477.07,-1509.31,20.54,50,0,0);
Create3DTextLabel("The Pier (LS)\nCost:6500\nEarning:500\n/prophelp",0x008080FF,390.35,-2045.67,7.82,50,0,0);
Create3DTextLabel("The Grand Hotel (LS)\nCost:4900\nEarning:370\n/prophelp",0x008080FF,330.39,-1512.43,35.74,50,0,0);
Create3DTextLabel("Victim\nCost:4900\nEarning:370\ n/prophelp",0x008080FF,218.25,-7.98,1001.21,50,0,0);
Create3DTextLabel("Didier Sachs\nCost:7500\nEarning:420\n/prophelp",0x008080FF,204.36,-160.11,1000.52,50,0,0);
Create3DTextLabel("Shopping Mall (LS)\nCost:7500\nEarning:650\n/prophelp",0x008080FF,1129.03,-1457.43,15.77,50,0,0);
Create3DTextLabel("Porn Cinema (LS)\nCost:3500\nEarning:150\n/prophelp",0x008080FF,1123.03,-1130.56,23.79,50,0,0);
Create3DTextLabel("Los Santos Theatre\nCost:4600\nEarning:600\n/prophelp",0x008080FF,1022.59,-1125.06,23.87,50,0,0);
Create3DTextLabel("Maddogs Mansion\nCost:6500\nEarning:1000\n/prophelp",0x008080FF,1254.06,-814.33,84.12,50,0,0);
Create3DTextLabel("The Lighthouse (LS)\nCost:3200\nEarning:160\n/prophelp",0x008080FF,154.13,-1945.42,4.63,50,0,0);
Create3DTextLabel("RS Haul\nCost:3500\nEarning:200\n/prophelp",0x008080FF,-78.05,-1135.93,1.07,50,0,0);
Create3DTextLabel("TruckStop\nCost:3500\nEarning:1 70\n/prophelp",0x008080FF,-24.95,-2509.12,36.63,50,0,0);
Create3DTextLabel("Whetstone GasStation\nCost:4500\nEarning:250\n/prophelp",0x008080FF,-1552.88,-2740.37,48.74,50,0,0);
Create3DTextLabel("Liquorshop Anglepine\nCost:3600\nEarning:250\n/prophelp",0x008080FF,-2105.31,-2432.12,30.62,50,0,0);
Create3DTextLabel("Trailerpark AnglePine\nCost:3500\nEarning:150\n/prophelp",0x008080FF,-2087.30,-2526.87,30.42,50,0,0);
Create3DTextLabel("Police Station Anglepine\nCost:2800\nEarning:250\n/prophelp",0x008080FF,-2162.76,-2387.10,30.62,50,0,0);
Create3DTextLabel("Chill Dogs\nCost:1500\nEarning:170\n/prophelp",0x008080FF,-2198.87,-2387.08,30.62,50,0,0);
Create3DTextLabel("The Junkjard\nCost:4600\nEarning:250\n/prophelp",0x008080FF,-1918.56,-1732.56,21.75,50,0,0);
Create3DTextLabel("San Andreas Watercompany\nCost:9500\nEarning:1110\n/prophelp",0x008080FF,-2062.29,-859.84,32.15,50,0,0);
Create3DTextLabel("San Fiero Stadium\nCost:6500\nEarning:750\n/prophelp",0x008080FF,-2124.36,-445.04,35.52,50,0,0);
Create3DTextLabel("Drivingschool (SF)\nCost:7500\nEarning:650\n/prophelp",0x008080FF,-2022.31,-99.66,35.15,50,0,0);
Create3DTextLabel("San Fiero Airport\nCost:13000\nEarning:1150\n/prophelp",0x008080FF,-1418.64,-292.79,14.14,50,0,0);
Create3DTextLabel("Fightclub 'Cobra' (SF)\nCost:1900\nEarning:250\n/prophelp",0x008080FF,-2268.62,-152.52,35.31,50,0,0);
Create3DTextLabel("Zero's RC\nCost:3500\nEarning:290\n/prophelp",0x008080FF,-2244.12,133.11,35.31,50,0,0);
Create3DTextLabel("Garage Doherty\nCost:6500\nEarning:750\n/prophelp",0x008080FF,-2027.38,148.36,28.79,50,0,0);
Create3DTextLabel("San Fiero Trainstation\nCost:7500\nEarning:650\n/prophelp",0x008080FF,-1983.31,137.99,27.68,50,0,0);
Create3DTextLabel("Wang Cars\nCost:8500\nEarning:1100\n/prophelp",0x008080FF,-1961.56,296.35,35.45,50,0,0);
Create3DTextLabel("Buildingsite (SF)\nCost:3500\nEarning:250\n/prophelp",0x008080FF,-2121.84,208.63,34.86,50,0,0);
Create3DTextLabel("Royal Hotel (SF)\nCost:5500\nEarning:650\n/prophelp",0x008080FF,-2418.62,333.60,35.15,50,0,0);
Create3DTextLabel("The Biffin Bridge Hotel\nCost:7500\nEarning:550\n/prophelp",0x008080FF,-2460.12,135.77,34.83,50,0,0);
Create3DTextLabel("Area 69\nCost:18000\nEarning:2200\n/prophelp",0x008080FF,214.00,1864.00,13.00,50,0,0);
Create3DTextLabel("Emerald Isle\nCost:7500\nEarning:1200\n/prophelp",0x008080FF,2127.4175,2378.3376,10.8203,5 0,0,0);
Create3DTextLabel("Auto Bahn\nCost:5000\nEarning:900\n/prophelp",0x008080FF,2171.7334,1408.8651,11.0625,5 0,0,0);
Create3DTextLabel("Chinatown LV\nCost:8500\nEarning:1100\n/prophelp",0x008080FF,2531.3330,1823.0336,10.8203,5 0,0,0);
Create3DTextLabel("San Andreas Police Dept.\nCost:13000\nEarning:1500\n/prophelp",0x008080FF,2248.4155,2453.1904,10.8203,5 0,0,0);
Create3DTextLabel("Golf Club LV\nCost:14000\nEarning:1600\n/prophelp",0x008080FF,1493.8583,2773.3938,10.8203,5 0,0,0);
Create3DTextLabel("Las Venturas Strip\nCost:16000\nEarning:1450\n/prophelp",0x008080FF,2057.6028,1532.8258,10.6719,5 0,0,0);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
//================================================== ================================================== ============================
//================================================== ================================================== ============================
//================================================== ================================================== ============================
if(strcmp(cmd, "/propertyhelp", true)==0 || strcmp(cmd, "/prophelp", true)==0)
{
SendClientMessage(playerid, 0x66CCFFAA, "/buyproperty or /buyprop ==>> To buy a property");
SendClientMessage(playerid, 0x66CCFFAA, "/sellproperty or /sellprop ==>> To sell one of your properties");
SendClientMessage(playerid, 0x66CCFFAA, "/myproperties or /myprops ==>> To see a list of all properties you own");
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, 0x66CCFFAA, "/sellallproperties [Admin Only] ==>> To sell all properties for all players");
}
SendClientMessage(playerid, 0x6699FFAA, "|================================================ =========|");
return 1;
}
//================================================== ================================================== ============================
//================================================== ================================================== ============================
//================================================== ================================================== ============================
if(strcmp(cmd, "/buyproperty", true)==0 || strcmp(cmd, "/buyprop", true)==0)
{
new str[128];
#if ENABLE_LOGIN_SYSTEM == 1
if(Logged[playerid] == 0)
{
format(str, 128, "You have to login before you can buy or sell properties! Use: %s", LOGIN_COMMAND);
SendClientMessage(playerid, 0xFF0000AA, str);
return 1;
}
#endif

new propid = IsPlayerNearProperty(playerid);

if(propid == -1)
{
SendClientMessage(playerid, 0xFF0000AA, "You're not close enough to a property");
return 1;
}
if(PlayerProps[playerid] == MAX_PROPERTIES_PER_PLAYER)
{
format(str, 128, "You already have %d properties, you can't buy more properties!", PlayerProps[playerid]);
SendClientMessage(playerid, 0xFF0000AA, str);
return 1;
}
if(PropInfo[propid][PropIsBought] == 1)
{
new ownerid = GetPlayerID(PropInfo[propid][PropOwner]);
if(ownerid == playerid)
{
SendClientMessage(playerid, 0xFF0000AA, "You already own this property!");
return 1;
}
else
{
if(PropInfo[propid][PropUnbuyableTime] > 0)
{
format(str, 128, "This property is already bought by %s.", PropInfo[propid][PropOwner], PropInfo[propid][PropUnbuyableTime]);
SendClientMessage(playerid, 0xFF0000AA, str);
return 1;
}
}
}
if(GetPlayerMoney(playerid) < PropInfo[propid][PropValue])
{
format(str, 128, "You don't have enough money! You need $%d,-", PropInfo[propid][PropValue]);
SendClientMessage(playerid, 0xFF0000AA, str);
return 1;
}
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
if(PropInfo[propid][PropIsBought] && PropInfo[propid][PropUnbuyableTime] == 0)
{
new ownerid = GetPlayerID(PropInfo[propid][PropOwner]);
format(str, 128, "%s has bought your property \"%s\". You recieved 50 percent of it's value ($%d)", pName, PropInfo[propid][PropName], (PropInfo[propid][PropValue]/2));
GivePlayerMoney(ownerid, (PropInfo[propid][PropValue]/2));
SendClientMessage(ownerid, 0xFFFF00AA, str);
PlayerProps[ownerid]--;
}
PropInfo[propid][PropOwner] = pName;
PropInfo[propid][PropIsBought] = 1;
PropInfo[propid][PropUnbuyableTime] = UNBUYABLETIME;
EarningsForPlayer[playerid] += PropInfo[propid][PropEarning];
GivePlayerMoney(playerid, (0-PropInfo[propid][PropValue]));
format(str, 128, "You have bought the property \"%s\" for $%d", PropInfo[propid][PropName], PropInfo[propid][PropValue]);
SendClientMessage(playerid, 0xFFFF00AA, str);
format(str, 128, "%s has bought the property \"%s\".", pName, PropInfo[propid][PropName]);
SendClientMessageToAllEx(playerid, 0xFFFFFFAA, str);
PlayerProps[playerid]++;
return 1;
}
//================================================== ================================================== ============================
//================================================== ================================================== ============================
//================================================== ================================================== ============================
if(strcmp(cmd, "/sellproperty", true) == 0 || strcmp(cmd, "/sellprop", true) == 0)
{
new str[128];
#if ENABLE_LOGIN_SYSTEM == 1
if(Logged[playerid] == 0)
{
format(str, 128, "You have to login before you can buy or sell properties! Use: %s", LOGIN_COMMAND);
SendClientMessage(playerid, 0xFF0000AA, str);
return 1;
}
#endif
new propid = IsPlayerNearProperty(playerid);
if(propid == -1)
{
SendClientMessage(playerid, 0xFF0000AA, "You're not close enough to a property");
return 1;
}
if(PropInfo[propid][PropIsBought] == 1)
{
new ownerid = GetPlayerID(PropInfo[propid][PropOwner]);
if(ownerid != playerid)
{
SendClientMessage(playerid, 0xFF0000AA, "You don't own this property!");
return 1;
}
}
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(PropInfo[propid][PropOwner], MAX_PLAYER_NAME, "Nobody");
PropInfo[propid][PropIsBought] = 0;
PropInfo[propid][PropUnbuyableTime] = 0;
GivePlayerMoney(playerid, (PropInfo[propid][PropValue]/2));
format(str, 128, "You have sold your property \"%s\" for 50 percents of its value: $%d,-", PropInfo[propid][PropName], PropInfo[propid][PropValue]/2);
SendClientMessage(playerid, 0xFFFF00AA, str);
format(str, 128, "%s has sold the property \"%s\".", pName, PropInfo[propid][PropName]);
SendClientMessageToAllEx(playerid, 0xFFFF00AA, str);
PlayerProps[playerid]--;
EarningsForPlayer[playerid] -= PropInfo[propid][PropEarning];
return 1;
}
//================================================== ================================================== ============================
//================================================== ================================================== ============================
//================================================== ================================================== ============================
if(strcmp(cmd, "/myproperties", true) == 0 || strcmp(cmd, "/myprops", true) == 0)
{
new str[128], ownerid;
#if ENABLE_LOGIN_SYSTEM == 1
if(Logged[playerid] == 0)
{
format(str, 128, "You have to login before you can buy or sell properties! Use: %s", LOGIN_COMMAND);
SendClientMessage(playerid, 0xFF0000AA, str);
return 1;
}
#endif
if(PlayerProps[playerid] == 0)
{
SendClientMessage(playerid, 0xFF0000AA, "You don't own a property!");
return 1;
}
format(str, 128, "|============ Your %d Properties: =============|", PlayerProps[playerid]);
SendClientMessage(playerid, 0x99FF66AA, str);
for(new propid; propid < PropertiesAmount; propid++)
{
if(PropInfo[propid][PropIsBought] == 1)
{
ownerid = GetPlayerID(PropInfo[propid][PropOwner]);
if(ownerid == playerid)
{
format(str, 128, ">> \"%s\" Value: $%d,- Earnings: $%d,-", PropInfo[propid][PropName], PropInfo[propid][PropValue], PropInfo[propid][PropEarning]);
SendClientMessage(playerid, 0x99FF66AA, str);
}
}
}
SendClientMessage(playerid, 0x99FF66AA, "|============================================ |");
return 1;
}
//================================================== ================================================== ============================
//================================================== ================================================== ============================
//================================================== ================================================== ============================
#if ENABLE_LOGIN_SYSTEM == 1
if(strcmp(cmd, REGISTER_COMMAND, true) == 0)
{
new str[128];
if(Logged[playerid] == 1) return SendClientMessage(playerid, 0xFF0000AA, "You're already logged in!");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
format(str, 128, "Use: %s 'Your Password'", REGISTER_COMMAND);
SendClientMessage(playerid, 0xFF9966AA, str);
return 1;
}
if(strlen(tmp) < 5) return SendClientMessage(playerid, 0xFF9966AA, "Password too short! At least 5 characters.");
if(strlen(tmp) > 20) return SendClientMessage(playerid, 0xFF9966AA, "Password too long! Max 20 characters.");
new pName[MAX_PLAYER_NAME], pass;
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
pass = dini_Int("PropertySystem/PlayerAccounts.txt", pName);
if(pass == 0)
{
dini_IntSet("PropertySystem/PlayerAccounts.txt", pName, encodepass(tmp));
Logged[playerid] = 1;
format(str, 128, "Your name is now registered in our property-database. Next time use \"%s %s\" to login", LOGIN_COMMAND, tmp);
SendClientMessage(playerid, 0x99FF66AA, str);
}
else
{
format(str, 128, "This name is already registered! Use %s to login!", LOGIN_COMMAND);
SendClientMessage(playerid, 0xFF9966AA, str);
}
return 1;
}
//================================================== ================================================== ============================
//================================================== ================================================== ============================
//================================================== ================================================== ============================
if(strcmp(cmd, LOGIN_COMMAND, true) == 0)
{
new str[128];
if(Logged[playerid] == 1) return SendClientMessage(playerid, 0xFF0000AA, "You're already logged in!");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
format(str, 128, "Use: %s 'Your Password'", LOGIN_COMMAND);
SendClientMessage(playerid, 0xFF9966AA, str);
return 1;
}
new pName[MAX_PLAYER_NAME], pass;
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
pass = dini_Int("PropertySystem/PlayerAccounts.txt", pName);
if(pass == 0)
{
format(str, 128, "This name is not registered yet! Use %s to register this name!", REGISTER_COMMAND);
SendClientMessage(playerid, 0xFF9966AA, str);
}
else
{
if(pass == encodepass(tmp))
{
Logged[playerid] = 1;
SendClientMessage(playerid, 0x99FF66AA, "You're now logged in! You can now buy and sell properties!");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "Wrong Password");
}
}
#if ENABLE_LOGIN_SYSTEM == 1
if(PlayerProps[playerid] > 0)
{
format(str, 128, "You currently own %d properties. Type /myproperties for more info about them.", PlayerProps[playerid]);
SendClientMessage(playerid, 0x99FF66AA, str);
}
#endif
return 1;
}
#endif
//================================================== ================================================== ============================
//================================================== ================================================== ============================
//================================================== ================================================== ============================
if(strcmp(cmd, "/sellallproperties", true)==0)
{
if(IsPlayerAdmin(playerid))
{
for(new propid; propid<PropertiesAmount; propid++)
{
format(PropInfo[propid][PropOwner], MAX_PLAYER_NAME, "Nobody");
PropInfo[propid][PropIsBought] = 0;
PropInfo[propid][PropUnbuyableTime] = 0;
}
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
PlayerProps[i] = 0;
}
}
new str[128], pName[24];
GetPlayerName(playerid, pName, 24);
format(str, 128, "Admin %s has reset all properties!", pName);
SendClientMessageToAll(0xFFCC66AA, str);
}
return 1;
}
//================================================== ================================================== ============================
//================================================== ================================================== ============================
//================================================== ================================================== ============================
return 0;
}


public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}

stock LoadProperties()
{
if(fexist("PropertySystem/PropertyInfo.txt"))
{
CountProperties();
new Argument[9][70];
new entry[256], BoughtProps;
new File: propfile = fopen("PropertySystem/PropertyInfo.txt", io_read);
if (propfile)
{
for(new id; id<PropertiesAmount; id++)
{
fread(propfile, entry);
split(entry, Argument, ',');
format(PropInfo[id][PropName], 64, "%s", Argument[0]);
PropInfo[id][PropX] = floatstr(Argument[1]);
PropInfo[id][PropY] = floatstr(Argument[2]);
PropInfo[id][PropZ] = floatstr(Argument[3]);
PropInfo[id][PropValue] = strval(Argument[4]);
PropInfo[id][PropEarning] = strval(Argument[5]);
format(PropInfo[id][PropOwner], MAX_PLAYER_NAME, "%s", Argument[6]);
PropInfo[id][PropIsBought] = strval(Argument[7]);
PropInfo[id][PropUnbuyableTime] = strval(Argument[8]);
PropInfo[id][PickupNr] = CreatePickup(1273, 1, PropInfo[id][PropX], PropInfo[id][PropY], PropInfo[id][PropZ]);
if(PropInfo[id][PropIsBought] == 1)
{
BoughtProps++;
}
}
fclose(propfile);
printf("===================================");
printf("|| Created %d Properties ||", PropertiesAmount);
printf("||%d of the properties are bought||", BoughtProps);
printf("===================================");
}
}
}

stock SaveProperties()
{
new entry[256];
new File: propfile = fopen("PropertySystem/PropertyInfo.txt", io_write);
for(new id; id<PropertiesAmount; id++)
{
format(entry, 128, "%s,%.2f,%.2f,%.2f,%d,%d,%s,%d,%d \r\n",PropInfo[id][PropName], PropInfo[id][PropX], PropInfo[id][PropY], PropInfo[id][PropZ], PropInfo[id][PropValue], PropInfo[id][PropEarning], PropInfo[id][PropOwner], PropInfo[id][PropIsBought], PropInfo[id][PropUnbuyableTime]);
fwrite(propfile, entry);
}
printf("Saved %d Properties!", PropertiesAmount);
fclose(propfile);
}

forward split(const strsrc[], strdest[][], delimiter);
public split(const strsrc[], strdest[][], delimiter)
{
new i, li;
new aNum;
new len;
while(i <= strlen(strsrc)){
if(strsrc[i]==delimiter || i==strlen(strsrc)){
len = strmid(strdest[aNum], strsrc, li, i, 12;
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}

stock CountProperties()
{
new entry[256];
new File: propfile = fopen("PropertySystem/PropertyInfo.txt", io_read);
while(fread(propfile, entry, 256))
{
PropertiesAmount++;
}
fclose(propfile);
}

forward IsPlayerNearProperty(playerid);
public IsPlayerNearProperty(playerid)
{
new Floatistance;
for(new prop; prop<PropertiesAmount; prop++)
{
Distance = GetDistanceToProperty(playerid, prop);
if(Distance < 1.0)
{
return prop;
}
}
return -1;
}

forward Float:GetDistanceToProperty(playerid, Property);
public Float:GetDistanceToProperty(playerid, Property)
{
new Float1,Float:y1,Float:z1,Float2,Float:y2,Float :z2;
GetPlayerPos(playerid,x1,y1,z1);
x2 = PropInfo[Property][PropX];
y2 = PropInfo[Property][PropY];
z2 = PropInfo[Property][PropZ];
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2 )+floatpower(floatabs(floatsub(y2,y1)),2)+floatpow er(floatabs(floatsub(z2,z1)),2));
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}

new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
stock GetPlayerID(const Name[])
{
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new pName[MAX_PLAYER_NAME];
GetPlayerName(i, pName, sizeof(pName));
if(strcmp(Name, pName, true)==0)
{
return i;
}
}
}
return -1;
}

stock SendClientMessageToAllEx(exeption, color, const message[])
{
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(i != exeption)
{
SendClientMessage(i, color, message);
}
}
}
}

forward UpdateUnbuyableTime();
public UpdateUnbuyableTime()
{
for(new propid; propid<PropertiesAmount; propid++)
{
if(PropInfo[propid][PropIsBought] == 1)
{
if(PropInfo[propid][PropUnbuyableTime] > 0)
{
PropInfo[propid][PropUnbuyableTime]--;
}
}
}
}

stock encodepass(buf[]) {
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}

forward MapIconStreamer();
public MapIconStreamer()
{
for(new i; i<MP; i++)
{
if(IsPlayerConnected(i))
{
new Float:SmallestDistance = 99999.9;
new CP, Float:OldDistance;
for(new propid; propid<PropertiesAmount; propid++)
{
OldDistance = GetDistanceToProperty(i, propid);
if(OldDistance < SmallestDistance)
{
SmallestDistance = OldDistance;
CP = propid;
}
}
RemovePlayerMapIcon(i, 31);
if(PropInfo[CP][PropIsBought] == 1)
{
SetPlayerMapIcon(i, 31, PropInfo[CP][PropX], PropInfo[CP][PropY], PropInfo[CP][PropZ], 32, 0);
}
else
{
SetPlayerMapIcon(i, 31, PropInfo[CP][PropX], PropInfo[CP][PropY], PropInfo[CP][PropZ], 31, 0);
}
}
}
}

forward PropertyPayout();
public PropertyPayout()
{
new str[64];
for(new i; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerProps[i] > 0)
{
GivePlayerMoney(i, EarningsForPlayer[i]);
format(str, 64, "{FFFFFF}You earned $%d from your properties!", EarningsForPlayer[i]);
SendClientMessage(i, 0xFFFF00AA, str);
}
}
}
}

Reply


Messages In This Thread
How to FIX THIS ? - by Rohit12 - 02.08.2017, 20:04
Re: How to FIX THIS ? - by Misiur - 02.08.2017, 20:11
Re: How to FIX THIS ? - by Xeon™ - 02.08.2017, 21:41
Re: How to FIX THIS ? - by Rohit12 - 02.08.2017, 21:56
Re: How to FIX THIS ? - by Rohit12 - 02.08.2017, 21:59
Re: How to FIX THIS ? - by Rohit12 - 04.08.2017, 02:27
Re: How to FIX THIS ? - by Rohit12 - 04.08.2017, 16:09

Forum Jump:


Users browsing this thread: 1 Guest(s)