Evict Renter Command -
AphexCCFC - 11.01.2013
Hello. I am trying to make it so if you type "/evictrenter" near the house it will evict the person who rents there even if they're offline, here is what I have:
pawn Код:
CMD:evictrenter(playerid, params[])
{
new string[128];
new h = Player[playerid][Houseid];
new c = GetClosetHouseID(playerid);
if(h == 999) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You don't have a house.");
if(!IsPlayerInRangeOfPoint(playerid,1.0,House[h][EnterX],House[h][EnterY],House[h][EnterZ])) return SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: You are not outside near your house.");
if(strcmp(House[h][Player_Rent],"Nobody", false ) == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: No one is lodging at your house.");
foreach(Player, renter)
{
if(Player[renter][RentHouseID] == c)
{
if(IsPlayerLoggedIn(renter))
{
format(string, sizeof(string), "Information{FFFFFF}: %s has evicted you from their house.", GetName(playerid));
SendClientMessage(playerid, COLOR_ORANGE, string);
}
Player[renter][RentHouseID] = 999;
PlayerInfo[renter][pRenting] = 0;
UpdatePlayerInformation(renter);
format(string, sizeof(string), "Information{FFFFFF}: You have evicted %s from your house.", GetName(renter));
SendClientMessage(playerid, COLOR_ORANGE, string);
format(House[h][Player_Rent], 32, "None");
return 1;
}
else
{
SendClientMessage(playerid,COLOR_LIGHTRED,"Error{FFFFFF}: No one is renting this house.");
return 1;
}
}
return 1;
}
Thank you, I will +rep.
Re: Evict Renter Command -
Infinity90 - 11.01.2013
You have basically explained what it is...Not what you need us to
help you with.
Respuesta: Evict Renter Command -
Fabio11 - 11.01.2013
He did a command to kick all the guys that rented that house, but he want the offline dudes to get kicked too.
You must open all the users files and find if the users are renting that house. Would be much easier with MySQL but well.
Re: Evict Renter Command -
AphexCCFC - 11.01.2013
Hmm, how would I go about that?
Respuesta: Evict Renter Command -
Fabio11 - 11.01.2013
Open each file of users in your user path, then check if the rent variable corresponds. Won't do it for you.
Re: Evict Renter Command -
AphexCCFC - 11.01.2013
Nope it doesn't.
Re: Evict Renter Command -
Jay_Dixon - 11.01.2013
Try something like this, this is the one my scripts using, and i can evict people offline with it
Код:
CMD:evict(playerid, params[])
{
new house = INVALID_HOUSE;
new Dude[MAX_PLAYER_NAME];
GetPlayerName(playerid, Dude, sizeof(Dude));
for(new h; h < MAX_HOUSES; h++)
{
if(HouseInfo[h][ID] > 0)
{
if(IsPlayerInRangeOfPoint(playerid, HOUSE_RANGE, HouseInfo[h][EntranceX], HouseInfo[h][EntranceY], HouseInfo[h][EntranceZ]) || PlayerInfo[playerid][pLocal] == h+1000)
{
if(!strcmp(HouseInfo[h][Owner], Dude))
{
house = h;
}
break;
}
}
}
if(house == INVALID_HOUSE)
{
SendClientMessage(playerid, COLOR_LIGHTRED, " You are not at your property!");
return 1;
}
if(strcmp(HouseInfo[house][Renter], "No-One", true) == 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, " Nobody is renting this property!");
return 1;
}
new string[128];
new RenterID;
RenterID = ReturnUser(HouseInfo[house][Renter]);
if(IsPlayerConnected(RenterID))
{
SendClientMessage(RenterID, COLOR_ORANGE, "Your landlord evicted you from your property.");
if(PlayerInfo[RenterID][pLocal] == 1000+house)
{
SetPlayerPos(RenterID, HouseInfo[house][EntranceX], HouseInfo[house][EntranceY], HouseInfo[house][EntranceZ]);
SetPlayerInterior(RenterID, 0);
SetPlayerVirtualWorld(RenterID, 0);
PlayerInfo[RenterID][pLocal] = 0;
}
PlayerInfo[RenterID][pRenting] = -1;
UpdatePlayer(RenterID);
}
else
{
format(UpdateQuery, sizeof(UpdateQuery), "UPDATE `userinfo` SET `Renting`= -2 WHERE `Username`='%s';", HouseInfo[house][Renter]);
}
format(string, sizeof(string), "* You evicted %s from your property.", HouseInfo[house][Renter]);
SendClientMessage(playerid, COLOR_LIGHTGREEN, string);
if(HouseInfo[house][Rentable] == 1)
{
format(string, sizeof(string), "For Rent\n$%d",HouseInfo[house][Rent]);
UpdateDynamic3DTextLabelText(HouseInfo[house][TextID], 0x2BFF00AA, string);
}
format(HouseInfo[house][Renter], 24, "No-One");
UpdateHouse(house);
return 1;
}
Re: Evict Renter Command -
AphexCCFC - 11.01.2013
I tried to make one like yours but epic fail.
Re: Evict Renter Command -
Infinity90 - 11.01.2013
Well, what saving system are you using?
Re: Evict Renter Command -
Steven82 - 11.01.2013
Just get the name of the player who rents the house and load that players file. I am currently doing that with y_ini for Pinewood until the conversion to MySQL is complete.