CMD:buygarage(playerid, params[])
{
new string[128];
new playername[MAX_PLAYER_NAME];
new sendername[MAX_PLAYER_NAME];
new Float:oldposx, Float:oldposy, Float:oldposz;
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
for(new h = 0; h < sizeof(GarageInfo); h++)
{
if(GarageInfo[h][gOwned] == 0 )
{
if(IsPlayerInRangeOfPoint(playerid,2.0,GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]) )
{
if(GetPlayerMoney(playerid) > GarageInfo[h][gValue])
{
PlayerInfo[playerid][pPgaragekey] = h;
GarageInfo[h][gOwned] = 1;
GetPlayerName(playerid, sendername, sizeof(sendername));
strmid(GarageInfo[h][gOwner], sendername, 0, strlen(sendername), 255);
GivePlayerMoney(playerid,-GarageInfo[h][gValue]);
SetPlayerInterior(playerid,GarageInfo[h][gHInteriorWorld]);
if(GarageInfo[h][gCustomInterior] == 1)
{
TogglePlayerControllable(playerid, 0);
GameTextForPlayer(playerid, "Loading....", 4000, 5);
SetPVarInt(playerid, "LoadingObjects", 1);
SetTimerEx("SafeLoadObjects", 4000, 0, "d", playerid);
}
SetPlayerPos(playerid,GarageInfo[h][gInteriorX],GarageInfo[h][gInteriorY],GarageInfo[h][gInteriorZ]);
GameTextForPlayer(playerid, "~w~Welcome Home~n~You can exit at any time by /exitgarage", 5000, 3);
SaveGarages();
SetPlayerVirtualWorld(playerid, h+6000);
DestroyDynamicPickup(GarageInfo[h][gPickupID]);
GarageInfo[h][gPickupID] = CreateDynamicPickup(1318, 23, GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]);
format(string, sizeof(string), "Garage Owned by\n %s\nID: %d",GarageInfo[h][gOwner],h);
UpdateDynamic3DTextLabelText(GarageInfo[h][gTextID], 0x33CCFFAA, string);
return 1;
}
else
{
SendClientMessage(playerid, 0x33CCFFAA, " You don't have the cash for that!");
return 1;
}
}
else
{
SendClientMessage(playerid, 0x33CCFFA, " You are not at a garage.");
}
}
else
{
SendClientMessage(playerid, 0x33CCFFA, "this garage is owned!");
}
}
return 1;
}
SendClientMessage(playerid, 0x33CCFFA, " You are not at a garage.");
for(new h = 0; h < sizeof(GarageInfo); h++) (This is the number of garages on the server) { if(GarageInfo[h][gOwned] == 0 ) (This means how many of them are not owned on the server) { if(IsPlayerInRangeOfPoint(playerid,2.0,GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]) ) { } else { SendClientMessage(playerid, 0x33CCFFA, " You are not at a garage."); (SendClientMessage will be called many times because if you have 2 not owned garages on the server, than it will call it 2 times, if there are 100 garages not owned than it will call this 100 times) }
if(IsPlayerInRangeOfPoint(playerid,2.0,GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]) )
new Float:GarageDistance = GetPlayerDistanceFromPoint(playerid, GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]);
if(GarageDistance == 5)
{
}
CMD:entergarage(playerid, params[])
{
for(new h = 0; h < sizeof(GarageInfo); h++)
{
if(IsPlayerInRangeOfPoint(playerid,2.0,GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]) )
{
if(GarageInfo[playerid][gOwned] == 1 )
{
SetPlayerPos(playerid,GarageInfo[h][gInteriorX],GarageInfo[h][gInteriorY],GarageInfo[h][gInteriorZ]);
GameTextForPlayer(playerid, "~w~Welcome to your garage!", 5000, 3);
}
else
{
SendClientMessage(playerid, 0x33CCFFAA, "You don't have a garage.");
}
}
else
{
SendClientMessage(playerid, 0x33CCFFAA, "You are not near to your garage to enter.");
}
}
return 1;
}
SendClientMessage(playerid, 0x33CCFFAA, "You are not near to your garage to enter."); |