LSPD Gate System
#1

I want to make a gate system. It opens when a player comes near it and closes when player goes away from it. I uses checkpoint to trigger this. I uses a checkpoint streamer: https://sampforum.blast.hk/showthread.php?tid=70963

My code is:

PHP код:
//objects
new lspdgate1;
new 
lspdgate2;
//checkpoints
new lspdcheckpoint;
new 
lspdgateopen=0;
//timers
new lspdgatetimer
On OnGameModeInit, I have this:
PHP код:
     //Objects
     //[LSPD]
     
lspdgate1=CreateObject(9751544.64209, -1622.2741713.99633,   0.000000.0000090.77937);
    
lspdgate2=CreateObject(9751544.68726, -1626.4851114.01554,   0.000000.0000090.39678);
    
CreateObject(9701547.58594, -1635.0065913.07822,   0.000000.0000091.75994);
    
CreateObject(9701545.51624, -1632.6993412.95227,   0.000000.000000.00000);
    
CreateObject(9751544.58704, -1619.3721914.01108,   0.000000.00000270.64969);
    
    
//Checkpoints
    //[LSPD]
     
CreateCheckpoint(GLOBAL_OWNER_IDlspdcheckpoint1544.3419,-1627.1494,13.3828);
    
UsePlayerPedAnims();
    
StartCheckpointSeeking(); 
On OnCheckpointEnter:
PHP код:
public OnCheckpointEnter(playeridcheckpointid)
{
    if(
checkpointid==lspdcheckpoint)
    {
        if(
lspdgateopen==0)
        {
            
MoveObject(lspdgate11544.64209, -1622.2741710.721361.0);
            
MoveObject(lspdgate21544.68726, -1626.4851110.721361.0);
            
lspdgatetimer=SetTimer("lspdgate"5000true);
            
lspdgateopen=1;
        }
    }
    return 
1;

A timer:
PHP код:
forward lspdgate();
public 
lspdgate()
{
     for(new 
i=0;i<MAX_PLAYERS;i++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
IsPlayerInCheckpoint(i)==lspdcheckpoint)
            {
                return 
1;
            }
        }
    }
    
KillTimer(lspdgatetimer);
    if(
lspdgateopen==1)
    {
        
MoveObject(lspdgate11544.64209, -1622.2741713.996331.0);
        
MoveObject(lspdgate21544.68726, -1626.4851114.015541.0);
        
lspdgateopen=0;
    }
    return 
1;

OnPlayerEnterCheckpoint:
PHP код:
public OnPlayerEnterCheckpoint(playerid)
{
    
VerifyCheckpoint(playerid);
    return 
1;

The problem is, the gate doesn't close when a player goes away from it.
It opens when a player enter that checkpoint, but doesn't close.
Also, if I stay in the checkpoint for 5 seconds, it closes, just opposite to what i wanted.

Please help me. (Rep++)
Reply


Messages In This Thread
LSPD Gate System - by ATGOggy - 06.12.2014, 06:40
Re: LSPD Gate System - by iiNzTicTx - 06.12.2014, 06:51
Re: LSPD Gate System - by ATGOggy - 06.12.2014, 06:59
Re: LSPD Gate System - by iiNzTicTx - 06.12.2014, 07:09
Re: LSPD Gate System - by ATGOggy - 06.12.2014, 07:12
Re: LSPD Gate System - by iiNzTicTx - 06.12.2014, 07:13
Re: LSPD Gate System - by ATGOggy - 06.12.2014, 07:17
Re: LSPD Gate System - by ATGOggy - 06.12.2014, 07:23
Re: LSPD Gate System - by ATGOggy - 06.12.2014, 07:26
Re: LSPD Gate System - by ATGOggy - 06.12.2014, 07:41

Forum Jump:


Users browsing this thread: 1 Guest(s)