SA-MP Forums Archive
moving gate with pass not working. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: moving gate with pass not working. (/showthread.php?tid=299152)



moving gate with pass not working. - reckst4r - 24.11.2011

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
    } 

Is there anything wrong with this script? Since when I go up next to the gate and write /gate hellsangels
nothing happends..

Thanks in advance.


Re: moving gate with pass not working. - System64 - 24.11.2011

pawn Код:
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  
            }  
        }
change to
pawn Код:
if(IsOpened == true)
        {
            IsOpened = false;
            SendClientMessage(playerid,-1,"Gate is closing!");
            MoveObject(Gate,969,1504.50000000,-699.70001221); //co-ordinates of closed gate
        }
        else
        {
               IsOpened = true;
            SendClientMessage(playerid,-1,"Gate is opening!");
            MoveObject(Gate,969,1512.00000000,-699.69897461); //co-ordinates of opened gate
        }



Re: moving gate with pass not working. - Pharrel - 24.11.2011

pawn Код:
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,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); //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
                //here is the error ^
                //right way:
                //MoveObject(Gate, X, Y, Z);
                //and you did:
                //MoveObject(Gate, objectid, X, Y);
            }
        }
        return 1;
    }
}



Re: moving gate with pass not working. - System64 - 24.11.2011

pahreel - are you crazy? MoveObject is ok, if is not he would get an error


Re: moving gate with pass not working. - Pharrel - 24.11.2011

Look at this:
pawn Код:
Gate = CreateObject(969,1504.50000000,-699.70001221,93.80000305,0.00000000,0.00000000,180.00000000); //object(electricgate) (1)
now look at this:
pawn Код:
MoveObject(Gate,969,1512.00000000,-699.69897461);//co-ordinates of opened gate
is this Ok for you??


Re: moving gate with pass not working. - reckst4r - 24.11.2011

Sorry, the script I putted was the old one that gave error..
The working one:

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;

I mean, this one compiles. The gate still aint opening with this.


Re: moving gate with pass not working. - reckst4r - 24.11.2011

Quote:
Originally Posted by System64
Посмотреть сообщение
pawn Код:
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  
            }  
        }
change to
pawn Код:
if(IsOpened == true)
        {
            IsOpened = false;
            SendClientMessage(playerid,-1,"Gate is closing!");
            MoveObject(Gate,969,1504.50000000,-699.70001221); //co-ordinates of closed gate
        }
        else
        {
               IsOpened = true;
            SendClientMessage(playerid,-1,"Gate is opening!");
            MoveObject(Gate,969,1512.00000000,-699.69897461); //co-ordinates of opened gate
        }
I tried that, but it still doesnt work


Re: moving gate with pass not working. - Pharrel - 24.11.2011

pawn Код:
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]");
        strdel(cmdtext, 0, strfind(cmdtext, " "));
        if(strcmp(cmdtext,password,true) != 0) 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;
}



Re: moving gate with pass not working. - reckst4r - 24.11.2011

That didn't work either


Re: moving gate with pass not working. - System64 - 24.11.2011

fuck, try without switching and everything, just put the moveobject