Gate System
#1

Hey folks!

I'm still trying to learn the basics so I could use some help...
In the following code there's somewhat of an "animation". The author has used a timer so it'll look more realstic. I'd like to remove that. In other words, I want it to be short and quick. Once I tap on the HORN button it'll open it without the realstic effect (same goes for the closing).

If someone could add an explanation that would be nice, thanks!


PHP код:
//this filterscript is made by EzeeCube, I don't care for credits if you need any help add me on skype peroplazar.
//you are free to give me some reputation in samp forum xD
#define FILTERSCRIPT
 
#include <a_samp>
 
#define MAX_GATES 2
 
new Gate[MAX_GATES],Gate1,Gate2;
 
forward pdcubegate0(playerid);
forward pdcubegate1(playerid);
forward pdcubegate2(playerid);
forward pdcubegate3(playerid);
forward pdcubegate4(playerid);
forward pdcubegate5(playerid);
forward pdcubegate6(playerid);
forward pdcubegate7(playerid);
forward pdcubegate8(playerid);
forward pdcubegate9(playerid);
forward pdcubegate10(playerid);
forward pdcubegate11(playerid);
forward pdcubegate12(playerid);
forward pdcubegate13(playerid);
forward pdcubegate14(playerid);
forward pdcubegate15(playerid);
forward pdcubegate16(playerid);
forward pdcubegate20(playerid);
 
public 
OnFilterScriptInit()
{
        
Gate[0] = CreateObject(971,1588.5000000,-1638.3000000,14.1000000,0.0000000,0.0000000,0.0000000);
        
Gate[1] = CreateObject(968,1544.7000000,-1630.8000000,13.1000000,0.0000000,90,89.4800415);
        return 
1;
}
 
public 
OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
                if(
newkeys && IsPlayerInAnyVehicle(playerid))
                {
                        if(
IsPlayerInRangeOfPoint(playerid,10,1588.5000000,-1638.3000000,14.1000000))
                        {
                                switch(
Gate1)
                                {
                                        case 
true:
                                        {
                                                
MoveObject(Gate[0],1598.5000000,-1638.3000000,14.1000000,5);
                                                
Gate1 false;
                                        }
                                        case 
false:
                                        {
                                                
MoveObject(Gate[0],1588.5000000,-1638.3000000,14.1000000,5);
                                                
Gate1 true;
                                        }
                                }
                        }
                        if(
IsPlayerInRangeOfPoint(playerid,10,1544.7000000,-1630.8000000,13.1000000))
                        {
                                switch(
Gate2)
                                {
                                        case 
true:
                                        {
                                                
SetObjectRotGate[1], 0,80,89.4800415);
                                                
SetTimer("pdcubegate1"100false);
                                        
SetTimer("ResetPD1",10000,0);
                                        }
                                        case 
false:
                                        {
                                                
SetObjectRotGate[1], 0,10,89.4800415);
                                                
SetTimer("pdcubegate8"100false);
                                        }
                                }
                        }
                }
}
public 
pdcubegate0()
{
        
SetObjectRotGate[1], 0,70,89.4800415);
        
SetTimer("pdcubegate1"100false);
        return 
1;
}
public 
pdcubegate1()
{
        
SetObjectRotGate[1], 0,60,89.4800415);
        
SetTimer("pdcubegate2"100false);
        return 
1;
}
public 
pdcubegate2()
{
        
SetObjectRotGate[1], 0,50,89.4800415);
        
SetTimer("pdcubegate3"100false);
        return 
1;
}
public 
pdcubegate3()
{
        
SetObjectRotGate[1], 0,40,89.4800415);
        
SetTimer("pdcubegate4"100false);
        return 
1;
}
public 
pdcubegate4()
{
        
SetObjectRotGate[1], 0,30,89.4800415);
        
SetTimer("pdcubegate5"100false);
        return 
1;
}
public 
pdcubegate5()
{
        
SetObjectRotGate[1], 0,20,89.4800415);
        
SetTimer("pdcubegate6"100false);
        return 
1;
}
public 
pdcubegate6()
{
        
SetObjectRotGate[1], 0,10,89.4800415);
        
SetTimer("pdcubegate7"100false);
        return 
1;
}
public 
pdcubegate7()
{
        
SetObjectRotGate[1], 0,0,89.4800415);
        
Gate2 false;
        return 
1;
}
public 
pdcubegate8()
{
        
SetObjectRotGate[1], 0,20,89.4800415);
        
SetTimer("pdcubegate9"100false);
        return 
1;
}
public 
pdcubegate9()
{
        
SetObjectRotGate[1], 0,30,89.4800415);
        
SetTimer("pdcubegate10"100false);
        return 
1;
}
public 
pdcubegate10()
{
        
SetObjectRotGate[1], 0,40,89.4800415);
        
SetTimer("pdcubegate11"100false);
        return 
1;
}
public 
pdcubegate11()
{
        
SetObjectRotGate[1], 0,50,89.4800415);
        
SetTimer("pdcubegate12"100false);
        return 
1;
}
public 
pdcubegate12()
{
        
SetObjectRotGate[1], 0,60,89.4800415);
        
SetTimer("pdcubegate13"100false);
        return 
1;
}
public 
pdcubegate13()
{
        
SetObjectRotGate[1], 0,70,89.4800415);
        
SetTimer("pdcubegate14"100false);
        return 
1;
}
public 
pdcubegate14()
{
        
SetObjectRotGate[1], 0,80,89.4800415);
        
SetTimer("pdcubegate15"100false);
        return 
1;
}
public 
pdcubegate15()
{
        
SetObjectRotGate[1], 0,90,89.4800415);
    
Gate2 true;
        return 
1;

Reply
#2

Use SetObjectPos instead of MoveObject.

The first one just set an object pos, and the second one move an object to a pos.
Reply
#3

Quote:
Originally Posted by arakuta
Посмотреть сообщение
Use SetObjectPos instead of MoveObject.

The first one just set an object pos, and the second one move an object to a pos.
I was talking about the 2nd gate , model id:968
Reply
#4

Bump
Reply
#5

pawn Код:
#include <a_samp>
#define MAX_GATES 2
new Gate[MAX_GATES][3];

public OnFilterScriptInit()
{
        Gate[0][0] = CreateObject(971, 1588.5000000, -1638.3000000, 14.1000000, 0.0000000, 0.0000000, 0.0000000);
        Gate[1][0] = CreateObject(968, 1544.7000000, -1630.8000000, 13.1000000, 0.0000000, 90, 89.4800415);
        Gate[0][1] = Gate[1][1] = 1;
        return 1;
}

public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
    if(newkeys & KEY_SUBMISSION)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(IsPlayerInRangeOfPoint(playerid, 10.0, 1588.5000000, -1638.3000000, 14.1000000))
            {
                if(Gate[0][1]) KillTimer(Gate[0][2]);
                MoveObject(Gate[0][0], (Gate[0][0]) ? (1598.5000000) : (1588.5000000), -1638.3000000, 14.1000000, 5, 0.0000000, 0.0000000, 0.0000000);
                Gate[0][1] = (Gate[0][1]) ? (0) : (1);
                Gate[0][2] = SetTimer("ResetGate1", 10000, false);
            }
            else if(IsPlayerInRangeOfPoint(playerid, 10.0, 1544.7000000, -1630.8000000, 13.1000000))
            {
                if(Gate[1][1]) KillTimer(Gate[1][2]);
                MoveObject(Gate[1][0], 1544.7000000, -1630.8000000, 13.1000001, 1, 0.0000000, (Gate[1][1]) ? (90.0000000) : (0.0000000), 89.4800415);
                Gate[1][1] = (Gate[1][1]) ? (0) : (1);
                Gate[1][2] = SetTimer("ResetGate2", 10000, false);
            }
        }
    }
    return 1;
}

forward ResetGate1();
forward ResetGate2();
public ResetGate1()
{
    MoveObject(Gate[0][0], 1588.5000000, -1638.3000000, 14.1000000, 5, 0.0000000, 0.0000000, 0.0000000);
    Gate[0][1] = 0;
    return 1;
}

public ResetGate2()
{
    MoveObject(Gate[1][0], 1544.7000000, -1630.8000000, 13.1000000, 1, 0.0000000, 90, 89.4800415);
    Gate[1][1] = 0;
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)