Spawn Player At House - If player don't have house? -
nGen.SoNNy - 14.08.2012
Hi all! I have a function wich spawn player to his house but if he don't have a housewill spawn in pos 0 0 0!
I just want to return an error if he don't own a house but i don't know where
I tried but fail! Please help! REP ++
pawn Код:
stock SpawnPlayerAtHouse(playerid)
{
foreach(Houses, i)
{
if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false) || !strcmp(HouseInfo[i][hRentUser], GetName(playerid), false) && HouseInfo[i][hOwned] == 1)
{
new HQuery2[200];
format(HQuery2, sizeof(HQuery2), "SELECT HouseID FROM `houses` WHERE `HouseID` = '%d'", i);
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1)
{
SendInfo(playerid, "Succesfuly spawned to your ~g~~h~House");
SetPlayerPos(playerid, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]);
SetPlayerInterior(playerid, HouseInfo[i][hInterior]);
SetPlayerVirtualWorld(playerid, HouseInfo[i][hVirtualWorld]);
PlayerEnteredHisHouse[playerid] = true;
mysql_free_result();
return 1;
}
}
}
return 0;
}
Re: Spawn Player At House - If player don't have house? -
Ballu Miaa - 14.08.2012
Sorry it is Untested. Try using it. Let me know what happens.
pawn Код:
stock SpawnPlayerAtHouse(playerid)
{
foreach(Houses, i)
{
if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false) || !strcmp(HouseInfo[i][hRentUser], GetName(playerid), false) && HouseInfo[i][hOwned] == 1)
{
new HQuery2[200];
format(HQuery2, sizeof(HQuery2), "SELECT HouseID FROM `houses` WHERE `HouseID` = '%d'", i);
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1)
{
SendInfo(playerid, "Succesfuly spawned to your ~g~~h~House");
SetPlayerPos(playerid, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]);
SetPlayerInterior(playerid, HouseInfo[i][hInterior]);
SetPlayerVirtualWorld(playerid, HouseInfo[i][hVirtualWorld]);
PlayerEnteredHisHouse[playerid] = true;
mysql_free_result();
return 1;
}
}
else
{
SetPlayerPos(playerid,1481.0189 , -1770.3466 , 18.7958 ); // Add your Coordinates here where you want the player to be spawned.
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
}
}
return 0;
}
Re: Spawn Player At House - If player don't have house? -
nGen.SoNNy - 14.08.2012
Same thing..
And if i'm trying to make like this.. to return an error .. always will return that error.. even if i have a house!
pawn Код:
stock SpawnPlayerAtHouse(playerid)
{
foreach(Houses, i)
{
if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false) || !strcmp(HouseInfo[i][hRentUser], GetName(playerid), false) && HouseInfo[i][hOwned] == 1)
{
new HQuery2[200];
format(HQuery2, sizeof(HQuery2), "SELECT HouseID FROM `houses` WHERE `HouseID` = '%d'", i);
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1)
{
SendInfo(playerid, "Succesfuly spawned to your ~g~~h~House");
SetPlayerPos(playerid, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]);
SetPlayerInterior(playerid, HouseInfo[i][hInterior]);
SetPlayerVirtualWorld(playerid, HouseInfo[i][hVirtualWorld]);
PlayerEnteredHisHouse[playerid] = true;
mysql_free_result();
return 1;
}
}
else return SendError(playerid, "You don't own a house ~g~~h~House");
}
return 0;
}
Re : Spawn Player At House - If player don't have house? -
BigBaws - 14.08.2012
Код:
stock SpawnPlayerAtHouse(playerid)
{
foreach(Houses, i)
{
if(!strcmp(HouseInfo[i][hOwner], GetName(playerid), false) || !strcmp(HouseInfo[i][hRentUser], GetName(playerid), false) && HouseInfo[i][hOwned] == 1)
{
new HQuery2[200];
format(HQuery2, sizeof(HQuery2), "SELECT HouseID FROM `houses` WHERE `HouseID` = '%d'", i);
mysql_query(HQuery2);
mysql_store_result();
if(mysql_num_rows() == 1)
{
SendInfo(playerid, "Succesfuly spawned to your ~g~~h~House");
SetPlayerPos(playerid, HouseInfo[i][hExitX], HouseInfo[i][hExitY], HouseInfo[i][hExitZ]);
SetPlayerInterior(playerid, HouseInfo[i][hInterior]);
SetPlayerVirtualWorld(playerid, HouseInfo[i][hVirtualWorld]);
PlayerEnteredHisHouse[playerid] = true;
mysql_free_result();
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_YELLOW," You dont own a house");
return 1;
}
}
return 0;
}
Try This dude
Re: Spawn Player At House - If player don't have house? -
nGen.SoNNy - 14.08.2012
it's the same thing
Didn't work
)