15.07.2014, 20:22
So, this is my code..
When someone do this cmd and offer the house to for example id 1, then the price will be 1 even if you offer the house for example 50000!? If you take id 2 the price will be 2 no matter what you type as the price it takes the ID of the player you're offering it to.. Why?
pawn Код:
if(strcmp(cmd, "/sellhouseto", true) == 0)
{
if(IsPlayerConnected(playerid))
{
GetPlayerName(playerid, playername, sizeof(playername));
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SCM(playerid, COLOR_GRAD1, "USAGE: /sellhouseto [playerid/PartOfName] [price]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(giveplayerid != INVALID_PLAYER_ID)
{
if(!strlen(tmp))
{
SCM(playerid, COLOR_GRAD1, "USAGE: /sellhouseto [playerid/PartOfName] [price]");
return 1;
}
new price,house;
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
house = PlayerInfo[playerid][pHouseKey];
price = strval(tmp);
if(price < 1 || price > 2000000) return SCM(playerid, COLOR_GRAD1, "Price can't be lower than 1 or higher than 2000000!");
if(PlayerInfo[playerid][pHouseKey] == 9999)
{
SCM(playerid, COLOR_WHITE, "You don't own a house.");
return 1;
}
if(PlayerInfo[playerid][pHouseKey] != 9999 && strcmp(playername, HouseInfo[PlayerInfo[playerid][pHouseKey]][hOwner], true) == 0)
{
format(string, sizeof(string),"%s Has offered you to buy his house for %i $.",playername, price);
SCM(giveplayerid, COLOR_RLRPGBLUE, string);
SCM(giveplayerid, COLOR_LIGHTGREEN,"To accept the offer, type /accept house");
format(string, sizeof(string),"You offered %s to buy your house for %i $.",giveplayer);
SCM(playerid, COLOR_RLRPGBLUE, string);
OfferHouse[giveplayerid] = playerid;
HouseInfo[house][hValue] = price;
OfferHouseKey[giveplayerid] = house;
}
}
else
{
SCM(playerid, COLOR_GREY,"Player is not online");
return 1;
}
}
return 1;
}