04.11.2011, 18:50
Hi all
I have a proble again, I use PVar in my stunt server and now I use them in house system, pvars that I used in my stunt server are almost the same as this in house but in house they doesn't work
So here is the script:
and this is in OnDialogResponse
So basicly, when I cancel the buying house it send 2 message to me but one should be for me and one for my friend (Player who typed /sellhouseto)
I have a proble again, I use PVar in my stunt server and now I use them in house system, pvars that I used in my stunt server are almost the same as this in house but in house they doesn't work
So here is the script:
pawn Код:
YCMD:sellhouseto(playerid, params[], help)
{
#pragma unused help
#pragma unused params
new id, selltostring[128];
for(new i = 0; i < MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ]))
{
if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false)) //if user is owner of house...
{
if(sscanf(params, "i", id)) return SendClientMessage(playerid, -1, "Usage: /sellhouseto [ID]");
else if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Invalid ID");
else if(id == playerid) return SendClientMessage(playerid, -1, "You can't sell house to yourself!");
if(!IsPlayerNearPlayer(playerid, id, 7.0)) return SendClientMessage(playerid, -1, "Player is not near you!");
format(selltostring, sizeof(selltostring), "Do you want to buy house from player %s for %d$?", GetName(playerid), HouseInfo[i][hPrice]/2);
ShowPlayerDialog(id, 5688, DIALOG_STYLE_MSGBOX, " Buy house", selltostring, "Yes", "No");
SetPVarInt(playerid, "SellToSeller", id);
}
}
}
return 1;
}
pawn Код:
case 5688: //sell to player house
{
new selledstring[128], selledstring2[128];
if(!response)
{
SendClientMessage(playerid, COLOR_YELLOW, "You canceled buying house!");
SendClientMessage(GetPVarInt(playerid, "SellToSeller"), COLOR_YELLOW, "Player canceled buying house!");
return 1;
}
for(new i = 0; i < MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(GetPVarInt(playerid, "SellToSeller"), 20.0, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]))
{
if(!strcmp(HouseInfo[i][hOwner], GetName(GetPVarInt(playerid, "SellToSeller")), false))
{
PlayerHaveHouse[playerid] = true;
PlayerHaveHouse[GetPVarInt(playerid, "SellToSeller")] = false;
format(HouseInfo[i][hOwner], 24, "%s", GetName(playerid));
format(HouseInfo[i][hRentUser], 24, "None");
HouseInfo[i][hOwned] = 1;
HouseInfo[i][hLocked] = 0;
HouseInfo[i][hRented] = 0;
GivePlayerMoney(playerid, -HouseInfo[i][hPrice]/2);
GivePlayerMoney(GetPVarInt(playerid, "SellToSeller"), HouseInfo[i][hPrice]/2);
if(HouseInfo[i][hRentDisabled] == 0)
{
DestroyPickup(HouseInfo[i][hPickup]);
HouseInfo[i][hPickup] = CreatePickup(1239, 23, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ], 0);
format(hstring, sizeof(hstring), "Owner: %s\nHouse ID: %d\nRent User: %s\nRent Price: %d", HouseInfo[i][hOwner], i, HouseInfo[i][hRentUser], HouseInfo[i][hRentPrice]);
Update3DTextLabelText(HouseInfo[i][hLabel], 0x21DD00FF, hstring);
}
else
{
DestroyPickup(HouseInfo[i][hPickup]);
HouseInfo[i][hPickup] = CreatePickup(1239, 23, HouseInfo[i][hEnterX], HouseInfo[i][hEnterY], HouseInfo[i][hEnterZ], 0);
format(hstring, sizeof(hstring), "Owner: %s\nHouse ID: %d\nRent Disabled", HouseInfo[i][hOwner], i);
Update3DTextLabelText(HouseInfo[i][hLabel], 0x21DD00FF, hstring);
}
format(selledstring, sizeof(selledstring), "You bought house from player %s for %d$", GetName(GetPVarInt(playerid, "SellToSeller")), HouseInfo[i][hPrice]/2);
SendClientMessage(playerid, COLOR_YELLOW, selledstring);
format(selledstring2, sizeof(selledstring2), "House sold to player %s for %d$", GetName(playerid), HouseInfo[i][hPrice]/2);
SendClientMessage(playerid, COLOR_YELLOW, selledstring2);
format(HQuery, sizeof(HQuery), "UPDATE `house` SET `User` = '%s', `Owned` = 1, `Locked` = 0, `Rent User` = 'None', `Rented` = 0 WHERE `HouseID` = %d", GetName(playerid), i);
mysql_query(HQuery);
}
}
}
}