Moving gate with pass errors
#1

Hello, I am trying to make a moving gate that moves when doing /gate hellsangels
The "hellsangels" at the end is a password for the gate.
Errors:

Код:
D:\Intense Roleplay\gamemodes\Gatetest.pwn(194) : warning 219: local variable "password" shadows a variable at a preceding level
D:\Intense Roleplay\gamemodes\Gatetest.pwn(238) : error 010: invalid function or declaration
D:\Intense Roleplay\gamemodes\Gatetest.pwn(241) : error 010: invalid function or declaration
D:\Intense Roleplay\gamemodes\Gatetest.pwn(243) : error 010: invalid function or declaration
D:\Intense Roleplay\gamemodes\Gatetest.pwn(244) : error 010: invalid function or declaration
D:\Intense Roleplay\gamemodes\Gatetest.pwn(245) : error 010: invalid function or declaration
D:\Intense Roleplay\gamemodes\Gatetest.pwn(246) : error 010: invalid function or declaration
D:\Intense Roleplay\gamemodes\Gatetest.pwn(248) : error 010: invalid function or declaration
D:\Intense Roleplay\gamemodes\Gatetest.pwn(254) : error 010: invalid function or declaration
D:\Intense Roleplay\gamemodes\Gatetest.pwn(261) : error 010: invalid function or declaration
D:\Intense Roleplay\gamemodes\Gatetest.pwn(265) : warning 203: symbol is never used: "Gate"
D:\Intense Roleplay\gamemodes\Gatetest.pwn(265) : warning 203: symbol is never used: "IsOpened"
D:\Intense Roleplay\gamemodes\Gatetest.pwn(265) : warning 203: symbol is never used: "password"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


9 Errors.
Script:
PHP код:
new    Gate,
    
bool:IsOpened,
    
password[24] = "hellsangels";
    
Gate CreateObject(969,1504.50000000,-699.70001221,93.80000305,0.00000000,0.00000000,180.00000000); //object(electricgate) (1)
IsOpened false//set it's status to closed
    
if(!strcmp("/gate",cmdtext,true))
    {
        if(!
IsPlayerInRangeOfPoint(playerid,10.0,x,y,z)) return SendClientMessage(playerid,-1"You aren't near any gate!");//replace with your gate x,y,z
        
if(strlen(cmdtext) < 7) return SendClientMessage(playerid,-1,"Usage: /gate [password]");
        if(
strcmp(cmdtext[7],password,true)) return SendClientMessage(playerid,-1,"Wrong Password!");
        switch(
IsOpened)
        {
            case 
true:
            {
                
IsOpened false;
                
SendClientMessage(playerid,-1,"Gate is closing!");
                
MoveObject(Gate,969,1504.50000000,-699.70001221); //co-ordinates of closed gate
            
}
               case 
false:
            {
                   
IsOpened true;
                
SendClientMessage(playerid,-1,"Gate is opening!");
                
MoveObject(Gate,969,1512.00000000,-699.69897461); //co-ordinates of opened gate
            
}
        }
        return 
1;
    }

Reply
#2

I gave you this code and it compiles without any error at my place. You know you have to add callbacks and #include <a_samp>?
Reply
#3

I do have #include <a_samp>
Callbacks?
How do I make callbacks for it? (I really suck at scripting)
Reply
#4

PHP код:
#include <a_samp>

new    Gate,
    
bool:IsOpened,
    
password[24] = "hellsangels";

public 
OnGameModeInit()
{
    
Gate CreateObject(969,1504.50000000,-699.70001221,93.80000305,0.00000000,0.00000000,180.00000000); //object(electricgate) (1)
    
IsOpened false//set it's status to closed
    
return 1;
}

public 
OnPlayerCommandText(playerid,cmdtext[])
{
    if(!
strcmp("/gate",cmdtext,true))
    {
        if(!
IsPlayerInRangeOfPoint(playerid,10.0,1504.50000000,-699.70001221,93.80000305)) return SendClientMessage(playerid,-1"You aren't near any gate!");//replace with your gate x,y,z
        
if(strlen(cmdtext) < 7) return SendClientMessage(playerid,-1,"Usage: /gate [password]");
        if(
strcmp(cmdtext[7],password,true)) return SendClientMessage(playerid,-1,"Wrong Password!");
        switch(
IsOpened)
        {
            case 
true:
            {
                
IsOpened false;
                
SendClientMessage(playerid,-1,"Gate is closing!");
                
MoveObject(Gate,1504.50000000,-699.70001221,93.80000305,5.0); //co-ordinates of closed gate
            
}
            case 
false:
            {
                
IsOpened true;
                
SendClientMessage(playerid,-1,"Gate is opening!");
                
MoveObject(Gate,1512.00000000,-699.69897461,93.80000305,5.0); //co-ordinates of opened gate
            
}
        }
        return 
1;
    }
    return 
0;

Reply
#5

Thanks, also should it be a filterscript or should it be in the gamemode?
Reply
#6

Doesn't matter. Would work even if it's in FS
Reply
#7

Nothing happends when I write /gate hellsangels
Doesn't say wrong password or that I aint near a gate.. Nothing..
Reply
#8

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
PHP код:
#include <a_samp>
new    Gate,
    
bool:IsOpened,
    
password[24] = "hellsangels";
public 
OnGameModeInit()
{
    
Gate CreateObject(969,1504.50000000,-699.70001221,93.80000305,0.00000000,0.00000000,180.00000000); //object(electricgate) (1)
    
IsOpened false//set it's status to closed
    
return 1;
}
public 
OnPlayerCommandText(playerid,cmdtext[])
{
    if(!
strcmp("/gate",cmdtext,true))
    {
        if(!
IsPlayerInRangeOfPoint(playerid,10.0,1504.50000000,-699.70001221,93.80000305)) return SendClientMessage(playerid,-1"You aren't near any gate!");//replace with your gate x,y,z
        
if(strlen(cmdtext) < 7) return SendClientMessage(playerid,-1,"Usage: /gate [password]");
        if(
strcmp(cmdtext[7],password,true)) return SendClientMessage(playerid,-1,"Wrong Password!");
        switch(
IsOpened)
        {
            case 
true:
            {
                
IsOpened false;
                
SendClientMessage(playerid,-1,"Gate is closing!");
                
MoveObject(Gate,1504.50000000,-699.70001221,93.80000305,5.0); //co-ordinates of closed gate
            
}
            case 
false:
            {
                
IsOpened true;
                
SendClientMessage(playerid,-1,"Gate is opening!");
                
MoveObject(Gate,1512.00000000,-699.69897461,93.80000305,5.0); //co-ordinates of opened gate
            
}
        }
        return 
1;
    }
    return 
0;

Do you mind if I ask why are you using
pawn Код:
if(strcmp(cmdtext[7],password,true)) return SendClientMessage(playerid,-1,"Wrong Password!");
? I mean the part of (cmdtext[7].
As the word "Hellsangels" isn't 7 letters, shouldn't that be longer?
Reply
#9

Well, I got the script from [MG]Dimi, I didn't create it and I dont understand pawno very well.. So are you saying that I should edit the cmdtex[7] to the amount of letters in the password (hellsangels) ?
Reply
#10

Quote:
Originally Posted by reckst4r
Посмотреть сообщение
Well, I got the script from [MG]Dimi, I didn't create it and I dont understand pawno very well.. So are you saying that I should edit the cmdtex[7] to the amount of letters in the password (hellsangels) ?
as far as I understand STRCMP, that could fix it, though i'm not sure.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)