06.03.2017, 17:07
I have a command to sell cells but it only allows you if you standing on cell A101 the first cell within the enum list
COMMAND
STOCK
COMMAND
Код:
CMD:sellcell(playerid, params[])
{
if(PlayerStat[playerid][Logged] != 1 || !IsPlayerConnected(playerid)) return SendErrorMessage(playerid, "Seems like you are not logged in!");
if(PlayerStat[playerid][Cuffed] == 1 || PlayerStat[playerid][Dead] == 1 || PlayerStat[playerid][InHospital] == 1) return SendErrorMessage(playerid, "You cannot use this command at the moment!");
if(PlayerStat[playerid][HasCell] == 0) return SendErrorMessage(playerid, "You don't have a cell you can sell!");
new c = GetCellIDFromSQLID(PlayerStat[playerid][Cell]);
new Confirmation[7], msg[255];
if(sscanf(params,"s[128]", Confirmation))return SendClientMessage(playerid, GREY, "Are you SURE you want to sell your cell? if yes, type this: /sellcell confirm");
else if(!strcmp(Confirmation, "confirm", true))
{
if(IsPlayerInRangeOfPoint(playerid, 1, CellSystem[c][CellEntPosX], CellSystem[c][CellEntPosY], CellSystem[c][CellEntPosZ]))
{
new cellPrice = CellSystem[c][CellPrice] / 2;
CellSystem[c][CellOwner] = -1;
CellSystem[c][CellLocked] = 1;
PlayerStat[playerid][HasCell] = 0;
PlayerStat[playerid][Cell] = -1;
CellSystem[c][CellLevel] = 0;
CellSystem[c][CellWeed] = 0;
CellSystem[c][CellCoke] = 0;
CellSystem[c][CellWeaponOne] = 0;
CellSystem[c][CellWeaponTwo] = 0;
GiveMoney(playerid, cellPrice);
DestroyDynamicPickup(CellSystem[c][CellPickup]);
DestroyDynamic3DTextLabel(Text3D:CellSystem[c][CellLabel]);
format(msg, sizeof(msg),"You have sold your cell (%s) for $%d.",CellSystem[c][CellName], cellPrice);
SendClientMessage(playerid,COLOR_GOLD,msg);
UpdateCellDetails©;
SaveCells©;
}
}
return true;
}
Код:
stock GetCellIDFromSQLID(sqlid)
{
new cellid;
for(new h = 0; h < sizeof(CellSystem); h ++)
{
if(CellSystem[h][CellSQLID] == sqlid)
{
cellid = h;
break;
}
}
return cellid;
}

