Problems with elses and ifs
#1

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(playeridparams[])
{
        if(
IsPlayerInRangeOfPoint(playerid452007.296631226.5278310.66455))
        {
        
SetPlayerPos(playerid2049.0613941.1595, -2.0587);
        }
            if(
GetPlayerState(playerid) !=1); //line 415
        
{
        
SendClientMessage(playerid0xE30000FF"[ERROR] You must be on foot to enter the house!");
                }
        else 
//line 419
        
{
        
SendClientMessage(playerid0xE30000FF"[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
Reply
#2

If-statements are never followed by a semicolon.
Reply
#3

That one mishap made me almost lose my mind!
Thank you lots, +rep'd!
Reply
#4

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
Reply
#5

Код:
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; 
}
Reply
#6

Thank you, appreciated!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)