SA-MP Forums Archive
/entergarage 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: /entergarage problem (/showthread.php?tid=448301)



/entergarage problem - Jermi - 03.07.2013

as i said before i made a garage system...
But /entergarage is bugged
When you are near to a garage, you must enter but it don't work, it says "You are not near to your garage entrance"
"You don't own a garage"

Codes of /entergarage:
pawn Код:
CMD:entergarage(playerid, params[])
{
    for(new h=1; h<MAX_GARAGE; h++)
    {
        new garageid;
        if(GarageInfo[playerid][gOwned] == 1 )
        {
            if(IsPlayerInRangeOfPoint(playerid,2.0,GarageInfo[garageid][gExteriorX], GarageInfo[garageid][gExteriorY], GarageInfo[garageid][gExteriorZ]) )
            {
                    SetPlayerPos(playerid,GarageInfo[garageid][gInteriorX],GarageInfo[garageid][gInteriorY],GarageInfo[garageid][gInteriorZ]);
                    GameTextForPlayer(playerid, "~w~Welcome to your garage!", 5000, 3);
            }
            if(h == MAX_GARAGE-1)
            {
                SendClientMessage(playerid, 0x33CCFFAA, "You are not near to your garage entrance! ");
            }
        }
        if(h == MAX_GARAGE-1)
        {
            SendClientMessage(playerid, 0x33CCFFAA, "You don't own a garage.");
        }
    }
    return 1;
}



Re: /entergarage problem - Zigonja - 03.07.2013

You cannot use
if and if again, you need to use if and then else if I belive.
Correct me if im wrong


Re: /entergarage problem - Jermi - 03.07.2013

You sure this works?


Re: /entergarage problem - Firewire - 03.07.2013

Zigonja is partly correct, there is no difference between using them both except that else if will only be called once the if statement above returns a false value. It works the same way as using else.


Re: /entergarage problem - kepa333 - 03.07.2013

Try like this
pawn Код:
CMD:entergarage(playerid, params[])
{
    for(new h = 1; h < MAX_GARAGE; h++)
    {
        if(GarageInfo[h][gOwned] == 1 )
        {
            if(IsPlayerInRangeOfPoint(playerid,2.0,GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]) )
            {
                    SetPlayerPos(playerid,GarageInfo[garageid][gInteriorX],GarageInfo[garageid][gInteriorY],GarageInfo[garageid][gInteriorZ]);
                    GameTextForPlayer(playerid, "~w~Welcome to your garage!", 5000, 3);
            }
            else
            {
                SendClientMessage(playerid, 0x33CCFFAA, "You are not near to your garage entrance! ");
            }
        }
        else
        {
            SendClientMessage(playerid, 0x33CCFFAA, "You don't own a garage.");
        }
    }
    return 1;
}



Re: /entergarage problem - Jermi - 03.07.2013

It was like that but Not working too


Re: /entergarage problem - kepa333 - 03.07.2013

Tell me, what was wrong with this one, what kind of bug it was?


Re: /entergarage problem - Jermi - 03.07.2013

Spam of You are not near to a garage and you don't own a garage
in 100 lines in the chat i think


Re: /entergarage problem - kepa333 - 03.07.2013

Im using system like this one... for my bizz system... try this one:

pawn Код:
CMD:entergarage(playerid, params[])
{
    for(new h = 0; h < (GarageInfo); h++)
    {
        if(GarageInfo[h][gOwned] == 1 )
        {
            if(IsPlayerInRangeOfPoint(playerid,2.0,GarageInfo[h][gExteriorX], GarageInfo[h][gExteriorY], GarageInfo[h][gExteriorZ]) )
            {
                    SetPlayerPos(playerid,GarageInfo[garageid][gInteriorX],GarageInfo[garageid][gInteriorY],GarageInfo[garageid][gInteriorZ]);
                    GameTextForPlayer(playerid, "~w~Welcome to your garage!", 5000, 3);
            }
            else
            {
                SendClientMessage(playerid, 0x33CCFFAA, "You are not near to your garage entrance! ");
            }
        }
        else
        {
            SendClientMessage(playerid, 0x33CCFFAA, "You don't own a garage.");
        }
    }
    return 1;
}
Problem in your code is, "GarageInfo[h][gOwned]", you got smthing like this "PlayerInfo[playerid][pGarageKey]"?