SA-MP Forums Archive
Moving gates with pass? - 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 gates with pass? (/showthread.php?tid=299092)



Moving gates with pass? - reckst4r - 24.11.2011

Hello, I were hoping that some of you could help me creating a script to open gates with a password.
What I imagined the command to be was something like: /opengate "pass"
For example.. /opengate westsideholmes

Thanks in advance.


Re: Moving gates with pass? - [MG]Dimi - 24.11.2011

PHP код:
new    Gate,
    
bool:IsOpened,
    
password[24] = "your_password";

//public OnGameModeInit()
Gate CreateObject(...); //create closed gate
IsOpened false//set it's status to closed

//public OnPlayerCommandText(playerid,cmdtext[])
    
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,...); //co-ordinates of closed gate
            
}
               case 
false:
               {
                   
IsOpened true;
                
SendClientMessage(playerid,-1,"Gate is opening!");
                
MoveObject(Gate,...); //co-ordinates of opened gate
            
}
        }
        return 
1;
    } 
It would be easier with ZCMD. I guess you use strcmp for commands


Re: Moving gates with pass? - reckst4r - 24.11.2011

Thanks alot, and yes I am using ZCMD.

Is the sa-mp mapping tool easier/better than MTA Mapping tool?
I am new to the mapping thing..


Re: Moving gates with pass? - [MG]Dimi - 24.11.2011

I got used to MTA so I use it but if I need to get default Mainland's object ID I use JernejL's Map Editor


Re: Moving gates with pass? - reckst4r - 24.11.2011

Thanks once again.
So, if you wanted to create a gate you would use MTA?


Re: Moving gates with pass? - [MG]Dimi - 24.11.2011

Yes. But it's all about which is more comfortable to you.


Re: Moving gates with pass? - reckst4r - 24.11.2011

Well, I guess I use MTA since the other map tool is lagging for me.


Re: Moving gates with pass? - reckst4r - 24.11.2011

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
PHP код:
new    Gate,
    
bool:IsOpened,
    
password[24] = "your_password";
//public OnGameModeInit()
Gate CreateObject(...); //create closed gate
IsOpened false//set it's status to closed
//public OnPlayerCommandText(playerid,cmdtext[])
    
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,...); //co-ordinates of closed gate
            
}
               case 
false:
               {
                   
IsOpened true;
                
SendClientMessage(playerid,-1,"Gate is opening!");
                
MoveObject(Gate,...); //co-ordinates of opened gate
            
}
        }
        return 
1;
    } 
It would be easier with ZCMD. I guess you use strcmp for commands
This script should be in my gamemode file (igrp.pwn) Right? Also the converted map file?