27.06.2016, 14:31
So i solved the first error from the previous post,but now it works partially.
Sometimes it works,sometimes it doesnt.
Code:
When you press F for /enter ,it works everytime.
But when you press F for /exit,it instantly teleports you outside and then back inside,so what cann i do? shall i create a timer or.. ? whats wrong with the code. i tried to reduce the range too..
Sometimes it works,sometimes it doesnt.
Code:
PHP код:
// new string[128],
new Query[128];
new faction = PlayerData[playerid][Member] + PlayerData[playerid][Leader];
for(new i = 1; i <= houses; i++)
{
if (PlayerToPoint(1, playerid,HouseInfo[i][hEntrancex], HouseInfo[i][hEntrancey], HouseInfo[i][hEntrancez]))
{
if(PlayerData[playerid][HKey] == i || HouseInfo[i][hLock] == 0)
{
SetPlayerInterior(playerid,HouseInfo[i][hInt]);
SetPlayerVirtualWorld(playerid,i);
SetPlayerPos(playerid,HouseInfo[i][hExitx],HouseInfo[i][hExity],HouseInfo[i][hExitz]);
GameTextForPlayer(playerid, "~w~Welcome home", 5000, 1);
PlayerData[playerid][InHouse] = i;
}
else
{
GameTextForPlayer(playerid, "~r~Closed", 5000, 1);
}
}
}
for(new i = 1; i <= bizzs; i++)
{
if(PlayerToPoint(1, playerid,BizzInfo[i][bEntranceX], BizzInfo[i][bEntranceY], BizzInfo[i][bEntranceZ]))
{
if(faction != 1 && (i == 1))
{
return 1;
}
if(PlayerData[playerid][Bizkey] == i || PlayerData[playerid][Cash] >= BizzInfo[i][bEntranceCost])
{
if(PlayerData[playerid][Bizkey] != i)
{
if(BizzInfo[i][bLocked] == 1) return GameTextForPlayer(playerid, "~r~Closed", 5000, 1);
if(BizzInfo[i][bProducts] == 0) return GameTextForPlayer(playerid, "~r~Out Of Stock", 5000, 1);
GivePlayerCash(playerid,-BizzInfo[i][bEntranceCost]);
format(string, sizeof(string), "~r~-$%d~n~~w~type /exit~n~to get out", BizzInfo[i][bEntranceCost]);
GameTextForPlayer(playerid, string, 5000, 3);
if(i != 1)
{
BizzInfo[i][bTill] += BizzInfo[i][bEntranceCost];
BizzInfo[i][bProducts]--;
mysql_format(SQL, Query,128,"UPDATE `bizz` SET `Till`='%d',`EntranceCost`='%d',`Products`='%d' WHERE `ID`='%d'",BizzInfo[i][bTill],BizzInfo[i][bEntranceCost],BizzInfo[i][bProducts],BizzInfo[i][bID]);
mysql_tquery(SQL, Query, "", "");
}
else
{
SafeBox[5][sbMoney] += BizzInfo[i][bEntranceCost];
mysql_format(SQL, Query,128,"UPDATE `safeboxs` SET `Money`='%d' WHERE `ID`='5'",SafeBox[5][sbMoney]);
mysql_tquery(SQL, Query, "", "");
}
}
SetPlayerInterior(playerid,BizzInfo[i][bInterior]);
SetPlayerVirtualWorld(playerid,BizzInfo[i][bVW]);
SetPlayerPos(playerid,BizzInfo[i][bExitX],BizzInfo[i][bExitY],BizzInfo[i][bExitZ]);
PlayerData[playerid][InBizz] = i;
}
else
{
GameTextForPlayer(playerid, "~r~You dont have the cash", 5000, 1);
}
}
}
if(((newkeys & (KEY_SECONDARY_ATTACK)) == (KEY_SECONDARY_ATTACK)) && ((oldkeys & (KEY_SECONDARY_ATTACK)) != (KEY_SECONDARY_ATTACK)))
{
if (PlayerToPoint(1.0, playerid,1412.0304,-1700.1549,13.5395))
{//enter cladire-spawn
SetPlayerPos(playerid,16.0883,33.4171,973.3144);
SetPlayerFacingAngle(playerid, 270.7579);
TogglePlayerControllable(playerid, 0);
SetTimerEx("UnfreezeT", 3000, 0, "d", playerid);
}
else if (PlayerToPoint(1.0, playerid,-1.3946,19.1643,973.3081))
{//sport room
SetPlayerPos(playerid,-1.3711,22.2146,973.4081);
}
else if (PlayerToPoint(1.0, playerid,22.1204,27.4664,973.3081))
{//main room
SetPlayerPos(playerid,22.1380,29.9197,973.3081);
}
else if (PlayerToPoint(1.0, playerid,22.2507,20.9277,973.3081))
{//rest room
SetPlayerPos(playerid,22.2184,18.6323,973.3081);
}
else if (PlayerToPoint(1.0, playerid,2486.5198,-1645.2394,14.0772) && faction == 2)
{//HQ Grove Street
PlayerData[playerid][InHQ] = 2;
SetPlayerPos(playerid,942.171997,-16.542755,1000.929687);
SetPlayerInterior(playerid,3);
SetPlayerVirtualWorld(playerid, 2);
}
else if (PlayerToPoint(1.0, playerid,2000.0482,-1114.3588,27.1250) && faction == 3)
{//Ballas
PlayerData[playerid][InHQ] = 3;
SetPlayerPos(playerid,964.106994,-53.205497,1001.124572);
SetPlayerInterior(playerid,3);
SetPlayerVirtualWorld(playerid, 3);
}
else if (PlayerToPoint(1.0, playerid,1899.4996,-2005.1289,13.5469) && faction == 4)
{//Varrio Nuevo Estrada
PlayerData[playerid][InHQ] = 4;
SetPlayerPos(playerid,1710.433715,-1669.379272,20.225049);
SetPlayerInterior(playerid,18);
SetPlayerVirtualWorld(playerid, 4);
}
else if (PlayerToPoint(1.0, playerid,1653.7765,-1655.5151,22.5156) && faction == 5)
{//SA GOV
PlayerData[playerid][InHQ] = 5;
SetPlayerPos(playerid,1494.3252,1304.9429,1093.2891);
SetPlayerInterior(playerid,3);
SetPlayerVirtualWorld(playerid, 5);
}
else if (PlayerToPoint(1.0, playerid,755.3737,-1362.3281,13.5131) && faction == 6)
{//SAN Network
PlayerData[playerid][InHQ] = 6;
SetPlayerPos(playerid,1494.3252,1304.9429,1093.2891);
SetPlayerInterior(playerid,3);
SetPlayerVirtualWorld(playerid, 6);
}
else if (PlayerToPoint(1.0, playerid,1172.4932,-1323.3479,15.4030) && faction == 7)
{//Emergency Dept.
PlayerData[playerid][InHQ] = 7;
SetPlayerPos(playerid,1494.3252,1304.9429,1093.2891);
SetPlayerInterior(playerid,3);
SetPlayerVirtualWorld(playerid, 7);
}
else if (PlayerToPoint(1.0, playerid,1555.2115,-1675.6229,16.1953))
{//LS - enter - section
SetPlayerPos(playerid,1118.5378,328.2394,583.7659);
SetPlayerFacingAngle(playerid, 90.0);
TogglePlayerControllable(playerid, 0);
SetTimerEx("UnfreezeT", 3000, 0, "d", playerid);
}
else if (PlayerToPoint(1.0, playerid,1117.6843,326.2397,583.7659))
{//section - enter - PD control
}
else if (PlayerToPoint(1.0, playerid,1127.5112,328.8745,583.7659))
{//section - enter - jail
}
if(PlayerData[playerid][InHouse] > 0)
{
new i = PlayerData[playerid][InHouse];
if (PlayerToPoint(1.0, playerid,HouseInfo[i][hExitx],HouseInfo[i][hExity],HouseInfo[i][hExitz])) // rezolvare bug enter exit
{
SetPlayerPos(playerid,HouseInfo[i][hEntrancex],HouseInfo[i][hEntrancey],HouseInfo[i][hEntrancez]+2);
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid, 0);
PlayerData[playerid][InHouse] = -1;
}
}
if(PlayerData[playerid][InBizz] > 0)
{
new i = PlayerData[playerid][InBizz];
if (PlayerToPoint(1.0, playerid,BizzInfo[i][bExitX],BizzInfo[i][bExitY],BizzInfo[i][bExitZ])) // rezolvare bug enter exit
{
PlayerData[playerid][InBizz] = -1;
SetPlayerInterior(playerid,0);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerPos(playerid,BizzInfo[i][bEntranceX],BizzInfo[i][bEntranceY],BizzInfo[i][bEntranceZ]+2);
}
}
else if (PlayerToPoint(1.0, playerid,-1.3711,22.2146,973.4081))
{//sport room
SetPlayerPos(playerid,-1.3946,19.1643,973.3081);
}
else if (PlayerToPoint(1.0, playerid,22.1380,29.9197,973.3081))
{//main room
SetPlayerPos(playerid,22.1204,27.4664,973.3081);
}
else if (PlayerToPoint(1.0, playerid,22.2184,18.6323,973.3081))
{//rest room
SetPlayerPos(playerid,22.2507,20.9277,973.3081);
}
else if (PlayerToPoint(1.0, playerid,38.1737,33.4262,973.3081))
{//exit spawn room
SetPlayerPos(playerid,1412.0304,-1700.1549,13.5395);
}
else if (PlayerToPoint(1.0, playerid,-15.9546,32.5763,973.3081))
{//exit spawn room
SetPlayerPos(playerid,1412.0304,-1700.1549,13.5395);
}
else if (PlayerToPoint(1.0, playerid,942.171997,-16.542755,1000.929687))
{//HQ Grove Street
PlayerData[playerid][InHQ] = -1;
SetPlayerPos(playerid,2486.5198,-1645.2394,14.0772);
SetPlayerVirtualWorld(playerid,0);
SetPlayerInterior(playerid,0);
}
else if (PlayerToPoint(1.0, playerid,964.106994,-53.205497,1001.124572))
{//Ballas
PlayerData[playerid][InHQ] = -1;
SetPlayerPos(playerid,2000.0482,-1114.3588,27.1250);
SetPlayerVirtualWorld(playerid,0);
SetPlayerInterior(playerid,0);
}
else if (PlayerToPoint(1.0, playerid,1710.433715,-1669.379272,20.225049))
{//Varrio Nuevo Estrada
PlayerData[playerid][InHQ] = -1;
SetPlayerPos(playerid,1899.4996,-2005.1289,13.5469);
SetPlayerVirtualWorld(playerid,0);
SetPlayerInterior(playerid,0);
}
else if (PlayerToPoint(1.0, playerid,1494.3252,1304.9429,1093.2891) && PlayerData[playerid][InHQ] == 5)
{//SA GOV
PlayerData[playerid][InHQ] = -1;
SetPlayerPos(playerid,1653.7765,-1655.5151,22.5156);
SetPlayerVirtualWorld(playerid,0);
SetPlayerInterior(playerid,0);
}
else if (PlayerToPoint(1.0, playerid,1494.3252,1304.9429,1093.2891) && PlayerData[playerid][InHQ] == 6)
{//SAN Network
PlayerData[playerid][InHQ] = -1;
SetPlayerPos(playerid,755.3737,-1362.3281,13.5131);
SetPlayerVirtualWorld(playerid,0);
SetPlayerInterior(playerid,0);
}
else if (PlayerToPoint(1.0, playerid,1494.3252,1304.9429,1093.2891) && PlayerData[playerid][InHQ] == 7)
{//Emergency Dept.
PlayerData[playerid][InHQ] = -1;
SetPlayerPos(playerid,1172.4932,-1323.3479,15.4030);
SetPlayerVirtualWorld(playerid,0);
SetPlayerInterior(playerid,0);
}
else if (PlayerToPoint(1.0, playerid,1119.1720,330.5911,583.7659))
{//section - exit - LS
SetPlayerPos(playerid,1552.3688,-1675.5404,16.1953);
SetPlayerFacingAngle(playerid, 90.0);
}
}
But when you press F for /exit,it instantly teleports you outside and then back inside,so what cann i do? shall i create a timer or.. ? whats wrong with the code. i tried to reduce the range too..