Gate Help
#1

I am trying to add a moving gate in sa-mp 0.3e but everytime I try and get the second set of cords in mta it crashes if someone could help me it would be greatly appreciated here are my 2 gate cords that need a command to open them
gate preferably goes down

Gate 1: CreateObject(971, -1060.2998046875, -1338.19921875, 132.5, 0, 0, 347.99743652344);



Gate 2: CreateObject(971, -1046.7998046875, -1334.3994140625, 132.60000610352, 0, 0, 347.99743652344)
Reply
#2

pawn Код:
// top
new gate[2];

// where you create the gates
gate[0] = CreateObject(971, -1060.2998046875, -1338.19921875, 132.5, 0, 0, 347.99743652344);
gate[1] = CreateObject(971, -1046.7998046875, -1334.3994140625, 132.60000610352, 0, 0, 347.99743652344);

// under OnPlayerCommandText
if(strcmp("/opengate1", cmdtext, true) == 0)
{
    MoveObject(gate[0], -1060.2998046875, -1338.19921875, 126.5, 7.5); // just decreased the 132.5 (Z value) by -6 (Change that as you like)
    /*
        Decrease the Z coordinate to make it move down.
    */

    return 1;
}
/*
    Continue, make a command to open the second gate just like I did above.
    But make sure to change gate[0] to gate[1] and also the coords.
*/
Reply
#3

Quote:
Originally Posted by HellSphinX
Посмотреть сообщение
pawn Код:
// top
new gate[2];

// where you create the gates
gate[0] = CreateObject(971, -1060.2998046875, -1338.19921875, 132.5, 0, 0, 347.99743652344);
gate[1] = CreateObject(971, -1046.7998046875, -1334.3994140625, 132.60000610352, 0, 0, 347.99743652344);

// under OnPlayerCommandText
if(strcmp("/opengate1", cmdtext, true) == 0)
{
    MoveObject(gate[0], -1060.2998046875, -1338.19921875, 126.5, 7.5); // just decreased the 132.5 (Z value) by -6 (Change that as you like)
    /*
        Decrease the Z coordinate to make it move down.
    */

    return 1;
}
/*
    Continue, make a command to open the second gate just like I did above.
    But make sure to change gate[0] to gate[1] and also the coords.
*/
I dont know what you mean by decrease by 6 here is my second gate code does it look right? for gate 2

// top
new gate[1];

// where you create the gates
gate[1] = CreateObject(971, -1046.7998046875, -1334.3994140625, 132.60000610352, 0, 0, 347.99743652344);

// under OnPlayerCommandText
if(strcmp("/o1", cmdtext, true) == 0)
{
MoveObject(gate[1], -1046.7998046875, -1334.3994140625, 126.5, 7.5); // just decreased the 132.5 (Z value) by -6 (Change that as you like)
/*
Decrease the Z coordinate to make it move down.
*/
return 1;
}


I seem to get error

C:\Users\Stephen\Downloads\heli.pwn(55) : error 010: invalid function or declaration
C:\Users\Stephen\Downloads\heli.pwn(61) : error 010: invalid function or declaration
C:\Users\Stephen\Downloads\heli.pwn(67) : error 010: invalid function or declaration
C:\Users\Stephen\Downloads\heli.pwn(74) : error 021: symbol already defined: "gate"
C:\Users\Stephen\Downloads\heli.pwn(77) : error 010: invalid function or declaration
C:\Users\Stephen\Downloads\heli.pwn(80) : error 010: invalid function or declaration
C:\Users\Stephen\Downloads\heli.pwn(86) : error 010: invalid function or declaration
C:\Users\Stephen\Downloads\heli.pwn(276) : warning 203: symbol is never used: "gate"
Reply
#4

I thought you want to make it move down, don't you? Decreasing the Z coord makes it go down.

Also you needn't have changed new gate[2]; to new gate[1];, let everything as I gave you just add your /o1 command code under my comment. This comment:
pawn Код:
/*    
       Continue, make a command to open the second gate just like I did above.    
       But make sure to change gate[0] to gate[1] and also the coords.
*/
And the errors are because the wrong placement. Like
pawn Код:
gate[0] = CreateObject(971, -1060.2998046875, -1338.19921875, 132.5, 0, 0, 347.99743652344);
gate[1] = CreateObject(971, -1046.7998046875, -1334.3994140625, 132.60000610352, 0, 0, 347.99743652344);
should be under OnGameModeInit or OnFilterScriptInit. And the commands must be under OnPlayerCommandText
Reply
#5

Quote:
Originally Posted by HellSphinX
Посмотреть сообщение
I thought you want to make it move down, don't you? Decreasing the Z coord makes it go down.

Also you needn't have changed new gate[2]; to new gate[1];, let everything as I gave you just add your /o1 command code under my comment. This comment:
pawn Код:
/*    
       Continue, make a command to open the second gate just like I did above.    
       But make sure to change gate[0] to gate[1] and also the coords.
*/
And the errors are because the wrong placement. Like
pawn Код:
gate[0] = CreateObject(971, -1060.2998046875, -1338.19921875, 132.5, 0, 0, 347.99743652344);
gate[1] = CreateObject(971, -1046.7998046875, -1334.3994140625, 132.60000610352, 0, 0, 347.99743652344);
should be under OnGameModeInit or OnFilterScriptInit. And the commands must be under OnPlayerCommandText
I dont understand im still trying to learn scripting
Reply
#6

Cool. Open up the gamemode you're working on, CTRL+F then search for OnGameModeInit (Read more about it here.) once you find it add these 2 lines into it

pawn Код:
gate[0] = CreateObject(971, -1060.2998046875, -1338.19921875, 132.5, 0, 0, 347.99743652344);
gate[1] = CreateObject(971, -1046.7998046875, -1334.3994140625, 132.60000610352, 0, 0, 347.99743652344);
Now, when the gamemode starts it will create the gates. Now let's place the commands, CTRL+F then find OnPlayerCommandText (Read more about it here) and add these codes into it

pawn Код:
if(strcmp("/opengate1", cmdtext, true) == 0)
{
    MoveObject(gate[0], -1060.2998046875, -1338.19921875, 126.5, 7.5);
    return 1;
}
if(strcmp("/o1", cmdtext, true) == 0)
{
    MoveObject(gate[1], -1046.7998046875, -1334.3994140625, 126.5, 7.5);
    return 1;
}
Still don't get it? See FULL CODE!
Reply
#7

Problem
Reply
#8

Use IsPlayerAdmin

pawn Код:
if(strcmp("/opengate1", cmdtext, true) == 0)
{
    if(IsPlayerAdmin(playerid))
    {
        MoveObject(gate[0], -1060.2998046875, -1338.19921875, 126.5, 7.5);
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by HellSphinX
Посмотреть сообщение
Use IsPlayerAdmin

pawn Код:
if(strcmp("/opengate1", cmdtext, true) == 0)
{
    if(IsPlayerAdmin(playerid))
    {
        MoveObject(gate[0], -1060.2998046875, -1338.19921875, 126.5, 7.5);
    }
    return 1;
}
C:\Users\Stephen\Downloads\heli.pwn(59) : warning 217: loose indentation
C:\Users\Stephen\Downloads\heli.pwn(90) : error 030: compound statement not closed at the end of file (started at line 72)

also
Reply
#10

Compiles fine for me. Where did you put it? Did you put it like that?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)