Gate command
#1

Well with me just recently figuring out moving gate commands, i was wondering if i can just have it in one command that opens and closes it. Would the script have to check where the object was or what?
currently this is just to close one
Код:
   	
if (strcmp(cmdtext, "/side2",true)==0)
        {
        MoveObject(sidegate, 2898.43139648,2132.76831055,13.79024315, 2.500000);
        return 1;
        }
Reply
#2

First create object:
pawn Код:
gate = CreateObject(980, 2793.449951, 3880.148438, 4.679246, 0.0000, 0.0000, 180.0000); // Gate Closed
The command to open:
pawn Код:
if(!strcmp(cmdtext,"/open",true ))
    {
        MoveObject(gate,2793.435303, 3880.137695, 10.504232,2);
        return 1;
    }
Close:
pawn Код:
if(!strcmp(cmdtext,"/close",true ))
    {
        MoveObject(gate,2793.449951, 3880.148438, 4.679246,2);
        return 1;
    }
Reply
#3

but isnt there a way to combine open and close? i know how to make the seperate commands.
Reply
#4

Код:
   	
if (strcmp(cmdtext, "/side2",true)==0)
        {
new Float:x, Float:y, Float:z;
GetObjectPos(sidegate, x, y, z);
new intx, inty, intz;
intx = floatround(x * 100, FLOATROUND_ROUND);
inty = floatround(y * 100, FLOATROUND_ROUND);
intz = floatround(z * 100, FLOATROUND_ROUND);
if (x == openxpos && y == openypos && z == openzpos)
{
        MoveObject(sidegate, 2898.43139648,2132.76831055,13.79024315, 2.500000);
}
else if (intx == 2898431 && inty == 2132768 && intz == 13790)
{
MoveObject(sidegate, openxpos, openypos, openzpos, 2.500000);
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "Gate is in motion");
        return 1;
        }
the rounding stuff is because you have too many decimals, and I am afraid it won't equal that exact number.
Reply
#5

When i try putting it in i get 22 errors, and me being kind of new to this i havent a clue what they're on about.
Код:
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(340) : error 017: undefined symbol "FLOATROUND_ROUND"
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(341) : error 017: undefined symbol "FLOATROUND_ROUND"
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(342) : error 017: undefined symbol "FLOATROUND_ROUND"
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(343) : error 017: undefined symbol "openxpos"
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(349) : error 017: undefined symbol "openxpos"
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(356) : warning 217: loose indentation
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(359) : warning 217: loose indentation
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(359) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(359) : error 004: function "OnPlayerExitVehicle" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(364) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(364) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(364) : error 004: function "OnPlayerStateChange" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(369) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(369) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(369) : error 004: function "Streamer_OnPlayerEnterCP" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(374) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(374) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(374) : error 004: function "Streamer_OnPlayerLeaveCP" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(379) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(379) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(379) : error 004: function "Streamer_OnPlayerEnterRaceCP" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(384) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(384) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(384) : error 004: function "Streamer_OnPlayerLeaveRaceCP" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(389) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(389) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(389) : error 004: function "OnRconCommand" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(393) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(393) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(393) : error 004: function "OnPlayerRequestSpawn" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(399) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(399) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(399) : error 004: function "OnObjectMoved" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(403) : error 030: compound statement not closed at the end of file (started at line 284)
Reply
#6

Quote:
Originally Posted by Hobod
Посмотреть сообщение
but isnt there a way to combine open and close? i know how to make the seperate commands.
Why not just do something like this:

EDIT: Forgot to add in the create object - but you know how to do it

pawn Код:
new GateStat;
GateStat = 0;
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/gatethingblah", cmdtext) == 0)
    {
        if(GateStat = 0) //If gate is closed
        {
            GateStat = 1; //Gate = Open
            MoveObject(blah, blah); //To open
            return 1;
        }
        else if(GateStat = 1) //If gate is open
        {
            GateStat = 0; //Gate = Closed
            MoveObject(blah, blah); //To closed
            return 1;
        }
    }
    return 0;
}
Something like that?

I havent tested it, its just something i thought of - i use it for stepping's of checkpoints on my new script and it works like a beauty
Reply
#7

i'll have a go with your way then
edit: i tried it in my gamemode and got errors.
so i then tried in just a blank script and got the same errors.
thats the full code there:
Код:
#include <a_samp>
new maingate;
new GateStat;

public OnGameModeInit()
{
	maingate = CreateObject(987,2894.78100586,2114.12182617,10.81382370,0.00000000,0.00000000,268.98352051);
	GateStat = 0;
return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/main", cmdtext) == 0)
    {
        if(GateStat = 0) //If gate is closed
        {
            GateStat = 1; //Gate = Open
            MoveObject(maingate, 2894.61962891,2106.19311523,10.81382370, 2.500000); //To open
            return 1;
        }
        else if(GateStat = 1) //If gate is open
        {
            GateStat = 0; //Gate = Closed
            MoveObject(maingate, 2894.78100586,2114.12182617,10.81382370, 2.500000); //To closed
            return 1;
        }
	return 1;
}
Код:
C:\Users\Mike\Desktop\Samp 0.3 Server\filterscripts\gates.pwn(9) : warning 217: loose indentation
C:\Users\Mike\Desktop\Samp 0.3 Server\filterscripts\gates.pwn(16) : warning 211: possibly unintended assignment
C:\Users\Mike\Desktop\Samp 0.3 Server\filterscripts\gates.pwn(22) : warning 211: possibly unintended assignment
C:\Users\Mike\Desktop\Samp 0.3 Server\filterscripts\gates.pwn(28) : warning 217: loose indentation
C:\Users\Mike\Desktop\Samp 0.3 Server\filterscripts\gates.pwn(30) : error 030: compound statement not closed at the end of file (started at line 14)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
but isnt that closed or what?
Reply
#8

Quote:
Originally Posted by Hobod
Посмотреть сообщение
When i try putting it in i get 22 errors, and me being kind of new to this i havent a clue what they're on about.
Код:
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(340) : error 017: undefined symbol "FLOATROUND_ROUND"
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(341) : error 017: undefined symbol "FLOATROUND_ROUND"
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(342) : error 017: undefined symbol "FLOATROUND_ROUND"
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(343) : error 017: undefined symbol "openxpos"
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(349) : error 017: undefined symbol "openxpos"
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(356) : warning 217: loose indentation
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(359) : warning 217: loose indentation
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(359) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(359) : error 004: function "OnPlayerExitVehicle" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(364) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(364) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(364) : error 004: function "OnPlayerStateChange" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(369) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(369) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(369) : error 004: function "Streamer_OnPlayerEnterCP" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(374) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(374) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(374) : error 004: function "Streamer_OnPlayerLeaveCP" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(379) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(379) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(379) : error 004: function "Streamer_OnPlayerEnterRaceCP" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(384) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(384) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(384) : error 004: function "Streamer_OnPlayerLeaveRaceCP" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(389) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(389) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(389) : error 004: function "OnRconCommand" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(393) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(393) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(393) : error 004: function "OnPlayerRequestSpawn" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(399) : warning 225: unreachable code
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(399) : error 029: invalid expression, assumed zero
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(399) : error 004: function "OnObjectMoved" is not implemented
C:\Users\Mike\Desktop\Samp 0.3 Server\gamemodes\troll.pwn(403) : error 030: compound statement not closed at the end of file (started at line 284)
Seriously, couldn't even fill in the blanks I left you?

and my mistake it is floatround_floor that you need, I had it capitalized.
Reply
#9

Well im still learning, but i did fill in the openypos and that lot in. and it gave me those errors
Reply
#10

There was a missing bracket and a missing equals sign. This compiled just fine.

pawn Код:
#include <a_samp>
new maingate;
new GateStat;

public OnGameModeInit()
{
    maingate = CreateObject(987,2894.78100586,2114.12182617,10.81382370,0.00000000,0.00000000,268.98352051);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp("/main", cmdtext) == 0)
    {
        if(GateStat == 0) //If gate is closed
        {
            GateStat = 1; //Gate = Open
            MoveObject(maingate, 2894.61962891,2106.19311523,10.81382370, 2.500000); //To open
        }
        else
        {
            GateStat = 0; //Gate = Closed
            MoveObject(maingate, 2894.78100586,2114.12182617,10.81382370, 2.500000); //To closed
        }
        return 1;
    }//Missing this
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)