Weird statement problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Weird statement problem (
/showthread.php?tid=358483)
Weird statement problem -
KreeDz - 10.07.2012
Hello,
I'm having quite a weird problem with the statements in samp, it's the only time I've met it so far. It seems to be no error, no bug, but it only happens on this line.
I'm working on a command for my own house system, but as I said, I just can't understand how this problems occurs and why, whenever I check for the house coordinates to see if the player is near the entrance of a house, the code following will execute as normal and when the player is not near the house coordinates it won't execute which is also normal. But there comes the problem, I wan't to return a message to the player saying that he is not near the house's entrance when trying to buy the house, but even though the code following the statement doesn't execute, it doesn't execute the message either even though it's supposed to do so.
This is the code:
Код:
if(!IsPlayerInRangeOfPoint(playerid,5.0,hData[hid][hEntX],hData[hid][hEntY],hData[hid][hEntZ])) return SendMsg(playerid,white,"You are not in the surroundings of a house.");
The thing is the return SendMsg(playerid,blabla,"some text"); just won't work when the player is away from a house. SendMsg is my shortened variant for SendClientMessage and it works perfectly ok.
Also, other things such as checking for the player's money works perfectly okay. Such as:
Код:
if(GetPlayerMoney(playerid) < hData[hid][Price]) return SendMsg(playerid,white,"You don't have enough money to buy this house.");
Hope someone can help, thanks.
Re: Weird statement problem -
coole210 - 10.07.2012
Are you looping through all the houses to see if they are at the entrance of any of them?
Example:
pawn Код:
new hid = -1;
for(new i = 0; i < MAX_HOUSES; i++)
{
if(IsPlayerInRangeOfPoint(playerid,5.0,hData[i][hEntX],hData[i][hEntY],hData[i][hEntZ]))
{
hid = i;
}
}
if(hid == -1) return SendMsg(playerid,white,"You are not in the surroundings of a house.");
Re: Weird statement problem -
KreeDz - 10.07.2012
EDIT: Auch... sorry for my stupidity. I just realized that I was checking if the file exists based on the house's id. It would return 1 when the id is under 1 which it always did when I was away from a house. Sorry again, problem fixed -.-