Gate Help
#1

i found this on samp wiki... and i have few questions..
do i need command for this, or no? I think that this doesnt need command
And how can i make that gate opens only for members of some faction, eg.
so here is the code

This goes to top of script:
Код:
new mygate;
This too:
Код:
forward CheckGate();
This goes to OnGameModeInit:
Код:
mygate = CreateObject(object_ID, closed_X, closed_Y, closed_Z, closed_rad_X, closed_rad_Y, closed_rad_Z)
Код:
public CheckGate()
{
    new mygate_status;
    for(new i;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInRangeOfPoint(i,10.0,closed_X,closed_Y,closed_Z))mygate_status=1;
    }
    if(mygate_status)MoveObject(mygate, open_X, open_Y, open_Z,Moving Speed);
    else MoveObject(mygate, closed_X, closed_Y, closed_Z, Moving Speed);
}
But where i put that gate opens only for members... And is this right?
Reply
#2

Yeah you don't need commands for this.
For a faction to open the gate to this:
pawn Код:
public CheckGate()
{
    new mygate_status;
    for(new i;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInRangeOfPoint(i,10.0,closed_X,closed_Y,closed_Z))mygate_status=1;
    }
    if (GetPlayerTeam(playerid) == /*Your faction here*/
    {
        if(mygate_status)MoveObject(mygate, open_X, open_Y, open_Z,Moving Speed);
        else MoveObject(mygate, closed_X, closed_Y, closed_Z, Moving Speed);
    }
    else
    {
        return 1;
    }
}
Reply
#3

Thanks
Reply
#4

Shit I missed a bracket:
pawn Код:
public CheckGate()
{
    new mygate_status;
    for(new i;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(IsPlayerInRangeOfPoint(i,10.0,closed_X,closed_Y,closed_Z))mygate_status=1;
    }
    if (GetPlayerTeam(playerid) == /*Your faction here*/)//This was my missing bracket.
    {
        if(mygate_status)MoveObject(mygate, open_X, open_Y, open_Z,Moving Speed);
        else MoveObject(mygate, closed_X, closed_Y, closed_Z, Moving Speed);
    }
    else
    {
        return 1;
    }
}
Wish you luck!
Reply
#5

Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)