06.08.2014, 01:11
Use this, fix the indentation though.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/compragarage", cmdtext, true) == 0)
{
new string[128], done;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(PlayerInfo[playerid][pGarage]) return SendClientMessage(playerid, COLOR_GREY, "You already own a garage.");
for(new idx=1; idx<MAX_GARAGES; idx++)
{
if(IsPlayerInRangeOfPoint(playerid, 3, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]))
{
if(!strcmp("The State", GarageInfo[idx][gOwner], false))
{
if(PlayerInfo[playerid][pMoney] < GarageInfo[idx][gPrice]) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money to buy this garage.");
GiveZaiatMoney(playerid, -GarageInfo[idx][gPrice]);
if(PlayerInfo[playerid][pGarage]) PlayerInfo[playerid][pGarage] = idx;
else PlayerInfo[playerid][pGarage] = idx;
format(GarageInfo[idx][gOwner], 32, "%s", RPNU(playerid));
format(string, sizeof(string), ""COE"["CWE"%d, Garage (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner]);
UpdateDynamic3DTextLabelText(GarageInfo[idx][gText], COLOR_WHITE, string);
SendClientMessage(playerid, COLOR_GREEN, " You have successfully bought a garage.");
format(string, sizeof(string), "%s has bought garage id %d.", RPN(playerid), idx);
Log("logs/garage.log", string);
idx = MAX_GARAGES;
done = 1;
}
if(idx == MAX_GARAGES-1 && !done)
{
SendClientMessage(playerid, COLOR_GREY, "This garage is owned by someone else.");
}
}
if(idx == MAX_GARAGES-1 && !done)
{
SendClientMessage(playerid, COLOR_GREY, "You are not near a buyable garage.");
}
}
return 1;
}
if(strcmp("/vendigarage", cmdtext, true) == 0)
{
new string[128], done;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!PlayerInfo[playerid][pGarage] && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a house.");
if(sscanf(params, "s[8]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /sellgaragetogov confirm");
if(!strcmp(params, "confirm", true))
{
new idx = PlayerInfo[playerid][pGarage];
if(IsPlayerInRangeOfPoint(playerid, 2, GarageInfo[PlayerInfo[playerid][pGarage]][gX], GarageInfo[PlayerInfo[playerid][pGarage]][gY], GarageInfo[PlayerInfo[playerid][pGarage]][gZ]))
{
GiveZaiatMoney(playerid, (75*GarageInfo[PlayerInfo[playerid][pGarage]][gPrice])/100);
format(GarageInfo[PlayerInfo[playerid][pGarage]][gOwner], 32, "The State");
format(string, sizeof(string), "ID: %d\nHouse (Lvl: %d)\nOwner: %s\nStatus: For Sale\nPrice: $%d", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner], GarageInfo[idx][gPrice]);
UpdateDynamic3DTextLabelText(GarageInfo[PlayerInfo[playerid][pGarage]][gText], COLOR_WHITE, string);
PlayerInfo[playerid][pGarage] = 0;
SendClientMessage(playerid, COLOR_GREEN, " You have successfully sold your house to The State. (75 percent of the original price was paid back)");
format(string, sizeof(string), "%s has sold house id %d to the market.", RPN(playerid), idx);
Log("logs/garage.log", string);
done = 1;
}
if(!done)
{
idx = PlayerInfo[playerid][pVHouse];
if(IsPlayerInRangeOfPoint(playerid, 3, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]))
{
GiveZaiatMoney(playerid, (75*GarageInfo[idx][gPrice])/100);
format(GarageInfo[idx][gOwner], 32, "The State");
format(string, sizeof(string), ""COE"["CWE"%d, Garage (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\nStatus: For Sale\n"CWE"$%d", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner], GarageInfo[idx][gPrice]);
UpdateDynamic3DTextLabelText(GarageInfo[idx][gText], COLOR_WHITE, string);
SendClientMessage(playerid, COLOR_GREEN, " You have successfully sold your garage to The State. (75 percent of the original price was paid back)");
format(string, sizeof(string), "%s has sold garage id %d to the market.", RPN(playerid), idx);
Log("logs/garage.log", string);
done = 1;
}
}
if(!done)
{
SendClientMessage(playerid, COLOR_GREY, "You are not near your garage.");
return 1;
}
}
return 1;
}
if(strcmp("/creagarage", cmdtext, true) == 0)
{
new string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login RCON.");
// if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
for(new idx=1; idx<MAX_GARAGES; idx++)
{
if(!GarageInfo[idx][gLevel])
{
// Getting Garage Setup
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
// Making Garage
GarageInfo[idx][gLevel] = 1;
GarageInfo[idx][gPrice] = 99999999;
format(GarageInfo[idx][gOwner], 32, "The State");
GarageInfo[idx][gX] = X;
GarageInfo[idx][gY] = Y;
GarageInfo[idx][gZ] = Z;
GarageInfo[idx][gPickup] = CreateDynamicPickup(1277, 1, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ], 0);
format(string, sizeof(string), ""COE"["CWE"%d, Garage (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\nStatus: For Sale\n"CWE"$%d", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner], GarageInfo[idx][gPrice]);
GarageInfo[idx][gText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]+0.3, 15);
format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created garage ID %d.", RPN(playerid), idx);
SendAdminMessage(COLOR_DARKRED, 1, string);
Log("logs/garage.log", string);
idx = MAX_GARAGES;
}
}
return 1;
}
if(strcmp("/rimuovigarage", cmdtext, true) == 0)
{
new id, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login RCON.");
// if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
if(sscanf(params, "i", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /deletegarage [garageid]");
if(!GarageInfo[id][gLevel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid garage id.");
foreach(Player, i)
{
if(IsPlayerLoggedIn(i) && PlayerInfo[i][pGarage] == id)
{
PlayerInfo[i][pGarage] = 0;
format(string, sizeof(string), " Administrator %s has deleted your garage.", RPN(playerid));
SendClientMessage(i, COLOR_WHITE, string);
}
}
if(!strcmp("The State", GarageInfo[id][gOwner]))
{
format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has deleted garage ID %d.", RPN(playerid), id);
}
else
{
format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has deleted %s's garage. (ID %d)", RPN(playerid), GarageInfo[id][gOwner], id);
}
SendAdminMessage(COLOR_DARKRED, 1, string);
Log("logs/garage.log", string);
GarageInfo[id][gLevel] = 0;
GarageInfo[id][gPrice] = 0;
format(GarageInfo[id][gOwner], 32, "");
GarageInfo[id][gX] = 0;
GarageInfo[id][gY] = 0;
GarageInfo[id][gZ] = 0;
DestroyDynamicPickup(GarageInfo[id][gPickup]);
DestroyDynamic3DTextLabel(GarageInfo[id][gText]);
return 1;
}
if(strcmp("/entra", cmdtext, true) == 0)
{
for(new idx=1; idx<MAX_GARAGES; idx++) // Dynamic Garages
{
if(IsPlayerInRangeOfPoint(playerid, 5, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ])/* && GetPlayerState(playerid) == PLAYER_STATE_DRIVER*/)
{
format(string, sizeof(string), "* %s enters the garage.", RPN(playerid));
if(PlayerInfo[playerid][pMaskOn] == 1)
{
format(string, sizeof(string), "* Stranger enters the garage.");
}
else
{
format(string, sizeof(string), "* %s enters the garage.", RPN(playerid));
}
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SetPlayerVirtualWorld(playerid, idx+500);
//SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), idx+500);
new vehicleid = GetPlayerVehicleID(playerid);
if(GarageInfo[idx][gLevel] == 1)
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, -2070.3000488281,-24,49.099998474121);
SetCameraBehindPlayer(playerid);
SetVehicleVirtualWorld(vehicleid, idx+500);
}
else
{
SetPlayerPos(playerid, -2070.3000488281,-24,49.099998474121);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
}
}
if(GarageInfo[idx][gLevel] == 2)
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, -2070.3000488281,-24,49.099998474121);
SetCameraBehindPlayer(playerid);
SetVehicleVirtualWorld(vehicleid, idx+500);
}
else
{
SetPlayerPos(playerid, -2070.3000488281,-24,49.099998474121);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
}
}
if(GarageInfo[idx][gLevel] == 3)
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, -2070.3000488281,-24,49.099998474121);
SetCameraBehindPlayer(playerid);
SetVehicleVirtualWorld(vehicleid, idx+500);
}
else
{
SetPlayerPos(playerid, -2070.3000488281,-24,49.099998474121);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
}
}
if(GarageInfo[idx][gLevel] == 4)
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, -2070.3000488281,-24,49.099998474121);
SetCameraBehindPlayer(playerid);
SetVehicleVirtualWorld(vehicleid, idx+500);
}
else
{
SetPlayerPos(playerid, -2070.3000488281,-24,49.099998474121);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
}
}
if(GarageInfo[idx][gLevel] == 5)
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, -2070.3000488281,-24,49.099998474121);
SetCameraBehindPlayer(playerid);
SetVehicleVirtualWorld(vehicleid, idx+500);
}
else
{
SetPlayerPos(playerid, -2070.3000488281,-24,49.099998474121);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
}
}
if(GarageInfo[idx][gLevel] == 6)
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, -2070.3000488281,-24,49.099998474121);
SetCameraBehindPlayer(playerid);
SetVehicleVirtualWorld(vehicleid, idx+500);
}
else
{
SetPlayerPos(playerid, -2070.3000488281,-24,49.099998474121);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
}
}
if(GarageInfo[idx][gLevel] == 7)
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, -2070.3000488281,-24,49.099998474121);
SetCameraBehindPlayer(playerid);
SetVehicleVirtualWorld(vehicleid, idx+500);
}
else
{
SetPlayerPos(playerid, -2070.3000488281,-24,49.099998474121);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
}
}
if(GarageInfo[idx][gLevel] == 8)
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, -2070.3000488281,-24,49.099998474121);
SetCameraBehindPlayer(playerid);
SetVehicleVirtualWorld(vehicleid, idx+500);
}
else
{
SetPlayerPos(playerid, -2070.3000488281,-24,49.099998474121);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
}
}
if(GarageInfo[idx][gLevel] == 9)
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, -2070.3000488281,-24,49.099998474121);
SetCameraBehindPlayer(playerid);
SetVehicleVirtualWorld(vehicleid, idx+500);
}
else
{
SetPlayerPos(playerid, -2070.3000488281,-24,49.099998474121);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
}
}
if(GarageInfo[idx][gLevel] == 10)
{
if(IsPlayerInAnyVehicle(playerid))
{
SetVehiclePos(vehicleid, -2070.3000488281,-24,49.099998474121);
SetCameraBehindPlayer(playerid);
SetVehicleVirtualWorld(vehicleid, idx+500);
}
else
{
SetPlayerPos(playerid, -2070.3000488281,-24,49.099998474121);
SetPlayerInterior(playerid, 0);
SetCameraBehindPlayer(playerid);
}
}
return 1;
}
}
return 1;
}
if(strcmp("/saveproject", cmdtext, true) == 0)
{
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login RCON.");
foreach(Player, i)
SaveGarages();
format(string, sizeof(string), "{FF0000}[Manual Save]{FF6347} Your Project has manualy saved!");
SendClientMessageToAll(COLOR_LIGHTRED, string);
return 1;
}
if(strcmp("/idgarage", cmdtext, true) == 0)
{
new bizid, string[128], input;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login RCON.");
// if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
if(sscanf(params, "s[32]", params))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gedit [option] [garageid]");
SendClientMessage(playerid, COLOR_GREY, "OPTIONS: location | price | level");
return 1;
}
if(!strcmp(params, "location", true, 8))
{
if(sscanf(params, "s[32]i", params, bizid)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ggedit location [house]");
new idx = bizid;
if(!GarageInfo[bizid][gLevel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid garage id.");
GetPlayerPos(playerid, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]);
DestroyDynamicPickup(GarageInfo[idx][gPickup]);
GarageInfo[idx][gPickup] = CreateDynamicPickup(1277, 1, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ], 0);
DestroyDynamic3DTextLabel(GarageInfo[idx][gText]);
if(!strcmp("The State", GarageInfo[idx][gOwner])) format(string, sizeof(string), ""COE"["CWE"%d, Garage (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\nStatus: For Sale\n"CWE"$%d", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner], GarageInfo[idx][gPrice]);
else format(string, sizeof(string), ""COE"["CWE"%d, Garage (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner]);
GarageInfo[idx][gText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]+0.3, 15);
format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has changed garage ID %d's location.", RPN(playerid), bizid);
SendAdminMessage(COLOR_DARKRED, 1, string);
Log("logs/garage.log", string);
}
else if(!strcmp(params, "price", true, 5))
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login RCON.");
if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ggedit price [garage] [price]");
new idx = bizid;
if(!GarageInfo[idx][gLevel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid garage id.");
if(strcmp("The State", GarageInfo[bizid][gOwner])) return SendClientMessage(playerid, COLOR_GREY, "You can't edit the price of owned garage.");
GarageInfo[bizid][gPrice] = input;
format(string, sizeof(string), ""COE"["CWE"%d, Garage (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\nStatus: For Sale\n"CWE"$%d", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner], GarageInfo[idx][gPrice]);
UpdateDynamic3DTextLabelText(GarageInfo[bizid][gText], COLOR_WHITE, string);
format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set Garage ID %d's price to $%d.", RPN(playerid), bizid, input);
SendAdminMessage(COLOR_DARKRED, 1, string);
Log("logs/garage.log", string);
}
else if(!strcmp(params, "level", true, 5))
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You must login RCON.");
if(sscanf(params, "s[32]ii", params, bizid, input)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ggedit level [garageid] [level]");
new idx = bizid;
//if(!GarageInfo[bizid][hLevel]) return SendClientMessage(playerid, COLOR_GREY, "Invalid garage id.");
if(input < 1 || input > 10) return SendClientMessage(playerid, COLOR_GREY, "Levels are between 1 and 10.");
GarageInfo[bizid][gLevel] = input;
if(!strcmp("The State", GarageInfo[idx][gOwner])) format(string, sizeof(string), ""COE"["CWE"%d, Garage (Lvl: %d)"COE"]\n"COE"Owner"CWE" %s\nStatus: For Sale\n"CWE"$%d", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner], GarageInfo[idx][gPrice]);
else format(string, sizeof(string), ""COE"["CWE"%d, Garage (Lvl: %d)\n"COE"\n"COE"Owner"CWE" %s", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner]);
UpdateDynamic3DTextLabelText(GarageInfo[bizid][gText], COLOR_WHITE, string);
format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has set garage ID %d's level to %d.", RPN(playerid), bizid, input);
SendAdminMessage(COLOR_DARKRED, 1, string);
Log("logs/garage.log", string);
}
return 1;
}
}