Problems with elses and ifs -
Bek_Loking - 09.03.2017
Hey, sorry for creating this thread for such a small problem, but I am completely demolished by it, I just recently got back into scripting as just a tiny hobby to spend time with, makes me feel good when I see that I made things by entering letters.
Basically. Code:
PHP код:
CMD:enterhouse(playerid, params[])
{
if(IsPlayerInRangeOfPoint(playerid, 45, 2007.29663, 1226.52783, 10.66455))
{
SetPlayerPos(playerid, 2049.0613, 941.1595, -2.0587);
}
if(GetPlayerState(playerid) !=1); //line 415
{
SendClientMessage(playerid, 0xE30000FF, "[ERROR] You must be on foot to enter the house!");
}
else //line 419
{
SendClientMessage(playerid, 0xE30000FF, "[ERROR] You are not near the house door!");
}
return 1;
}
THe errors are on the lines
415 - empty statement
419 - invalid expression, assumed zero
Basically what I want to do is the game to deny me if I want to enter my house while in my car
I also took a wild guess with the !=1 because ! means no and = means equal, so not equal 1
Thanks in advance, boys
Re: Problems with elses and ifs -
Vince - 09.03.2017
If-statements are never followed by a semicolon.
Re: Problems with elses and ifs -
Bek_Loking - 09.03.2017
That one mishap made me almost lose my mind!
Thank you lots, +rep'd!
Re: Problems with elses and ifs -
Bek_Loking - 09.03.2017
Follow-up question:
What do I have to write to make it return and not actually teleport me when I'm in a vehicle, because eg.
I'm in a vehicle and I write the command, and it teleports me into the house normally,but it also sends me a message that I can't enter the house while in a vehicle.
It also sends me a message if saying that I'm not in the range of the house, yet I still get teleported, it only won't teleport me if I'm actually not in the range. But if I am, it will tell me that I'm not in the range and it will teleport me
Re: Problems with elses and ifs -
ISmokezU - 09.03.2017
Код:
CMD:enterhouse(playerid, params[]) {
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xE30000FF, "[ERROR] You must be on foot to enter the house!");
if(IsPlayerInRangeOfPoint(playerid, 45, 2007.29663, 1226.52783, 10.66455))
{
SetPlayerPos(playerid, 2049.0613, 941.1595, -2.0587);
} else {
SendClientMessage(playerid, 0xE30000FF, "[ERROR] You are not near the house door!");
}
return 1;
}
Re: Problems with elses and ifs -
Bek_Loking - 09.03.2017
Thank you, appreciated!