24.09.2018, 10:48
PHP код:
CMD:rentprop(playerid, params[])
{
new playername[25], giveplayerid, giveplayer[25], tmp[2000], string[256], moneys1,strings[40], tmp2[200];
if (areatype[playerarea[playerid]][0] != AREA_TYPE_PROP) return SendClientMessage2(playerid, COLOR_RED, "Error: You must be at a property to rent it!");
GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
giveplayerid = dini_Int(AddDirFile(dir_userfiles, playername), "propowned");
if (giveplayerid != 0)
{
if (areatype[playerarea[playerid]][1] == giveplayerid) return SendClientMessage2(playerid, COLOR_YELLOW, "You already own this property.");
}
giveplayerid = dini_Int(AddDirFile(dir_userfiles, playername), "proprented");
if (giveplayerid != 0)
{
if (areatype[playerarea[playerid]][1] == giveplayerid) SendClientMessage2(playerid, COLOR_YELLOW, "You are already an tenant in this property.");
return 1;
}
format(giveplayer, 10, "prop%d", areatype[playerarea[playerid]][1]);
new maxtenants = dini_Int(AddDirFile(dir_propfiles, giveplayer), "maxtenants");
format(tmp2, 100, "renter%d", maxtenants+1);
moneys1 = dini_Int(AddDirFile(dir_propfiles, giveplayer), "rentcost");
if(moneys1 == 0) return SendClientMessage(playerid, COLOR_RED, "This property isnt set Let - To - Go.");
if (GetPlayerCash(playerid) < moneys1)
{
format(string, 128, "You don't have $%d and cannot rent this property!", moneys1);
SendClientMessage2(playerid, COLOR_RED, string);
return 1;
}
if (playerZone[playerid] > sizeof(zonenames)-11)
{
format(strings,sizeof(strings),"%s.",zonenames[playerZone[playerid]][z_name]);
}
else
{
format(strings,sizeof(strings),"%s, %s. ",zonenames[playerZone[playerid]][z_name], zonenames[sizeof(zonenames)-(zonetype[playerZone[playerid]]+1)][z_name]);
}
GivePlayerCash(playerid, -moneys1);
dini_IntSet(AddDirFile(dir_userfiles, playername), "proprented", areatype[playerarea[playerid]][1]);
dini_Set(AddDirFile(dir_userfiles, playername), "HouseLocation", strings);
dini_IntSet(AddDirFile(dir_propfiles, giveplayer), "tenants", maxtenants);
dini_IntSet(AddDirFile(dir_propfiles, giveplayer), "rented", 1);
dini_Set(AddDirFile(dir_propfiles, giveplayer), tmp2, RPN(playerid));
DestroyPickup(ppropids[areatype[playerarea[playerid]][1]]);
DestroyDynamicMapIcon(pmapicon[areatype[playerarea[playerid]][1]]);
new Float:x, Float:y, Float:z;
x = dini_Float(AddDirFile(dir_propfiles, giveplayer), "X");
y = dini_Float(AddDirFile(dir_propfiles, giveplayer), "Y");
z = dini_Float(AddDirFile(dir_propfiles, giveplayer), "Z");
ppropids[areatype[playerarea[playerid]][1]] = CreatePickup(19523, 1, x, y, z, -1);
pmapicon[areatype[playerarea[playerid]][1]] = CreateDynamicMapIcon(x, y, z, 32, 0, -1, 0, -1, 600.0, MAPICON_LOCAL);
new tmp3[200];
format(tmp3, sizeof(tmp3), "%s%s\n", tmp3, dini_Get(AddDirFile(dir_propfiles, giveplayer), tmp2));
format(tmp, sizeof(tmp), "Owner: %s\nTolet: $%d per day\nTenants: %s\n", dini_Get(AddDirFile(dir_propfiles, giveplayer), "owner"), dini_Int(AddDirFile(dir_propfiles, giveplayer), "rentcost"), tmp3);
Update3DTextLabelText(ptextlabel[areatype[playerarea[playerid]][1]], COLOR_ORANGE, tmp);
for (new i = 0; i < PLAYERS; i++)
{
if (IsPlayerInRangeOfPoint(i, 300.0, x, y, z)) Streamer_Update(i);
}
format(string, 128, "You have rented this property for $%d. Welcome to your new home.", moneys1);
SendClientMessage2(playerid, COLOR_GREEN, string);
GameTextForPlayer(playerid, "~g~~h~~h~Property rented!", 5000, 3);
return 1;
}
please
help
over
here