When I'm scripting my crate house/business command I'm actually opening and writing the INI file, not doing it the simpler way (to ensure it does what the command is meant to do.)
Код:
CMD:acreate(playerid, params[])
{
for(new i=0; i < MAX_PLAYERS; i++)
{
new admins = PlayerInfo[i][pAdmin] > 0;
if(strfind(params, "house", true))
{
new houseid, address, price, inint, message[256], alert[256], Float:px, Float:py, Float:pz, Float:entx, Float:enty, Float:entz, aname[64];
GetPlayerName(playerid, aname, 64);
new outint = GetPlayerInterior(playerid);
new outvir = GetPlayerVirtualWorld(playerid);
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_GREY, "Sorry, you aren't an admin!");
if(PlayerInfo[playerid][pAdmin] == 1 || 2 || 3) return SendClientMessage(playerid, COLOR_GREY, "Your admin level isn't high enough!");
if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "/acreatehouse [houseid] [address] [price] [interior (Default 7)] [X] [Y] [Z]");
if(sscanf(params,"uiuuuu", houseid, address, price, inint, entx, enty, entx))
if(houseid == PlayerInfo[i][pHouseID]) return SendClientMessage(playerid, COLOR_GREY, "This house ID is already taken!");
else
{
GetPlayerPos(playerid, px, py, pz);
new INI:File = INI_Open(HousePath(houseid));
INI_SetTag(File,"data");
INI_WriteFloat(File, "EnterX",px);
INI_WriteFloat(File, "EnterY",py);
INI_WriteFloat(File, "EnterZ",pz);
INI_WriteFloat(File, "ExitX",entx);
INI_WriteFloat(File, "ExitY",enty);
INI_WriteFloat(File, "ExitZ",entz);
INI_WriteInt(File, "Inside Interior",inint);
INI_WriteInt(File, "Outside Interior",outint);
INI_WriteInt(File, "Outside Virtual World",outvir);
INI_WriteBool(File, "Owned",false);
INI_WriteInt(File, "Price",price);
INI_WriteInt(File, "Locked",0);
INI_WriteInt(File, "Owner",-0);
((Line 2934)) INI_WriteString(File, "Address", address);
INI_Close(File);
format(alert, 256, "[ADMIN CMD] (/acreate house) %s (%d) has created a house ID %d at POS %f %f %f", aname, playerid, houseid, px, py, pz);
SendClientMessage(admins, COLOR_LIGHTYELLOW2, alert);
format(message, 256, "You have successfully created house ID %d at %f %f %f. The address is %s and interior ID is %d", houseid, px, py, pz, address, inint);
SendClientMessage(playerid, COLOR_GREEN, message);
}
}
if(strfind(params, "business", true))
{
new businessid, address, price, inint, message[256], alert[256], Float:px, Float:py, Float:pz, Float:entx, Float:enty, Float:entz, aname[64];
GetPlayerName(playerid, aname, 64);
new outint = GetPlayerInterior(playerid);
new outvir = GetPlayerVirtualWorld(playerid);
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, COLOR_GREY, "Sorry, you aren't an admin!");
if(PlayerInfo[playerid][pAdmin] == 1 || 2 || 3) return SendClientMessage(playerid, COLOR_GREY, "Your admin level isn't high enough!");
if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "/acreatehouse [houseid] [address] [price] [interior (Default 7)] [X] [Y] [Z]");
if(sscanf(params,"uiuuuu", businessid, address, price, inint, entx, enty, entx))
if(businessid == PlayerInfo[i][pBusinessID]) return SendClientMessage(playerid, COLOR_GREY, "This business ID is already taken!");
else
{
GetPlayerPos(playerid, px, py, pz);
new INI:File = INI_Open(BusinessPath(businessid));
INI_SetTag(File,"data");
INI_WriteFloat(File, "EnterX",px);
INI_WriteFloat(File, "EnterY",py);
INI_WriteFloat(File, "EnterZ",pz);
INI_WriteFloat(File, "ExitX",entx);
INI_WriteFloat(File, "ExitY",enty);
INI_WriteFloat(File, "ExitZ",entz);
INI_WriteInt(File, "Inside Interior",inint);
INI_WriteInt(File, "Outside Interior",outint);
INI_WriteInt(File, "Outside Virtual World",outvir);
INI_WriteBool(File, "Owned",false);
INI_WriteInt(File, "Price",price);
INI_WriteInt(File, "Locked",0);
INI_WriteInt(File, "Owner",-0);
((Line 2971)) INI_WriteString(File, "Address",address);
INI_Close(File);
format(alert, 256, "[ADMIN CMD] (/acreate business) %s (%d) has created a house ID %d at POS %f %f %f", aname, playerid, businessid, px, py, pz);
SendClientMessage(admins, COLOR_LIGHTYELLOW2, alert);
format(message, 256, "You have successfully created business ID %d at %f %f %f. The address is %s and interior ID is %d", businessid, px, py, pz, address, inint);
SendClientMessage(playerid, COLOR_GREEN, message);
}
}
}
return 1;
}
I'm using y_ini. Everything is properly defined, etc.