SA-MP Forums Archive
Using same command for another gate - 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: Using same command for another gate (/showthread.php?tid=361224)



Using same command for another gate - jeremy8810 - 20.07.2012

Hey guys,

Im making a toll-system that opens the gate with ''/toll'' and closing automaticly after severeal sec. No I have 2 gates (for both sides of the road) and I want to open both tolls with ''/toll'' the commands are checking if player is in range, but I can only use 1 gate....
Here the piece of my script for the command:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/toll", true))
    {
        if(IsPlayerInRangeOfPoint(playerid, 10.0, 1806.19921875, 926.7998046875, 8.3000001907349))
        {
            if(GetPlayerWantedLevel(playerid) > 3)
            {
                new tmp[64];
                format(tmp, sizeof(tmp), "Your current wanted level is: %i you cannot pass the toll! Find another way!", GetPlayerWantedLevel(playerid));
                SendClientMessage(playerid, 0xFF0000FF, tmp);
            }
            else
            {
                SetTimerEx("CloseGate", 3000, false, "i", playerid);
                SetPVarInt(playerid, "PVarMoney", -50);
               
                MoveObject(Gate, 1806.1999511719, 926.79998779297, 8.3000001907349, 3.0, 0.0, 359.25, 0.0);
                SendClientMessage(playerid, 0x006EFFFF, "You paid toll, you are ready to go!");
            }
        }
        return 1;
    }
    return 0;
}
Hope you know what I can do..
Mayebe I have to do:
else if PlayeInRangeOfPoitnt (the other gate)
opens that gate ?


Re: Using same command for another gate - Kindred - 20.07.2012

Simple enough, right?:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/toll", true))
    {
        if(IsPlayerInRangeOfPoint(playerid, 10.0, 1806.19921875, 926.7998046875, 8.3000001907349))
        {
            if(GetPlayerWantedLevel(playerid) > 3)
            {
                new tmp[64];
                format(tmp, sizeof(tmp), "Your current wanted level is: %i you cannot pass the toll! Find another way!", GetPlayerWantedLevel(playerid));
                SendClientMessage(playerid, 0xFF0000FF, tmp);
            }
            else
            {
                SetTimerEx("CloseGate", 3000, false, "i", playerid);
                SetPVarInt(playerid, "PVarMoney", -50);

                MoveObject(Gate, 1806.1999511719, 926.79998779297, 8.3000001907349, 3.0, 0.0, 359.25, 0.0);
                SendClientMessage(playerid, 0x006EFFFF, "You paid toll, you are ready to go!");
            }
        }
        if(IsPlayerInRangeOfPoint(playerid, 10.0, OtherPosX, OtherPosY, OtherPosZ))
        {
            if(GetPlayerWantedLevel(playerid) > 3)
            {
                new tmp[64];
                format(tmp, sizeof(tmp), "Your current wanted level is: %i you cannot pass the toll! Find another way!", GetPlayerWantedLevel(playerid));
                SendClientMessage(playerid, 0xFF0000FF, tmp);
            }
            else
            {
                SetTimerEx("CloseGate", 3000, false, "i", playerid);
                SetPVarInt(playerid, "PVarMoney", -50);

                MoveObject(Gate, OtherOtherPosX, OtherOtherPosY, OtherOtherPosZ, 3.0, 0.0, 359.25, 0.0);
                SendClientMessage(playerid, 0x006EFFFF, "You paid toll, you are ready to go!");
            }
        }
        return 1;
    }
    return 0;
}



Re: Using same command for another gate - jeremy8810 - 20.07.2012

Yeah okey, thanks!


Re: Using same command for another gate - Rudy_ - 20.07.2012

yes use else if(IsPlayerInRangeOfPoint ....
and detect which place near he is and open the nearest door.

Код:
This forum requires that you wait 120 seconds between posts. Please try again in 46 seconds.
Edit: Too late