About command

Started by Cena, Feb 21, 2016, 07:46 AM

Previous topic - Next topic

Cena

I make this cmds

else if ( cmd== "assault")
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(121,250);
MessagePlayer("[#00FFF7]You Are A assault Man Now",player);
player.IsFrozen = false;
}
else if ( cmd== "scout")
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(28,25);
MessagePlayer("[#00FFF7]You Are A Sniper Man Now",player);
player.IsFrozen = false;
}
else if ( cmd== "antitank")
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(111,10);
MessagePlayer("[#00FFF7]You Are A AntiTanker Now",player);
player.IsFrozen = false;
}
but i want it like if someone use /antitank and after it try to use /scout or /assault server say to that player you cant use this cmd cuz you chose antitanker and also i want no one can use /antitank, /scout and /assault twice

i try to make this kind of thing but fail can some one help me?. ( thank you in admvance :) )
Want To Meet Me Come #Cena At Lunet

KAKAN

Can't understand you lol
oh no

FarisDon

#2
Quote from: Cena on Feb 21, 2016, 07:46 AMI make this cmds

else if ( cmd== "assault")
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(121,250);
MessagePlayer("[#00FFF7]You Are A assault Man Now",player);
player.IsFrozen = false;
}
else if ( cmd== "scout")
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(28,25);
MessagePlayer("[#00FFF7]You Are A Sniper Man Now",player);
player.IsFrozen = false;
}
else if ( cmd== "antitank")
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(111,10);
MessagePlayer("[#00FFF7]You Are A AntiTanker Now",player);
player.IsFrozen = false;
}
but i want it like if someone use /antitank and after it try to use /scout or /assault server say to that player you cant use this cmd cuz you chose antitanker and also i want no one can use /antitank, /scout and /assault twice

i try to make this kind of thing but fail can some one help me?. ( thank you in admvance :) )
Put these arrays in the script, basically the main.nut we can say.
assaults <-array(GetMaxPlayers(),0);
scouts <-array(GetMaxPlayers(),0);
antitanks <-array(GetMaxPlayers(),0);
else if ( cmd== "assault")
{
if ( assaults[player.ID] != 1 )
{
if ( scouts[player.ID] == 0 )
{
if ( antitanks[player.ID] == 0 )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(121,250);
MessagePlayer("[#00FFF7]You Are A assault Man Now",player);
player.IsFrozen = false;
assaults[player.ID] = 1;
}
else ClientMessage("You can't use the command since you are an AntiTanker",player,255,255,0);
}
else ClientMessage("You can't use the command since you are a Scount",player,255,255,0);
}
else ClientMessage("You have already selected the "Assault"",player,255,255,0);
}
else if ( cmd== "scount")
{
if ( scouts[player.ID] != 1  )
{
if ( assaults[player.ID] == 0 )
{
if ( antitanks[player.ID] == 0 )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(28,25);
MessagePlayer("[#00FFF7]You Are A Sniper Man Now",player);
player.IsFrozen = false;
scouts[player.ID] = 1;
}
else ClientMessage("You can't use the command since you are an AntiTanker",player,255,255,0);
}
else ClientMessage("You can't use the command since you are a assaults",player,255,255,0);
}
else ClientMessage("You have already selected the "Scout"",player,255,255,0);
}
else if ( cmd== "antitank")
{
if ( antitanks[player.ID] != 1 )
{
if ( assaults[player.ID] == 0 )
{
if ( scouts[player.ID] == 0 )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(111,10);
MessagePlayer("[#00FFF7]You Are A AntiTanker Now",player);
antitanks[player.ID] = 1;
}
else ClientMessage("You can't use the command since you are a scount",player,255,255,0);
}
else ClientMessage("You can't use the command since you are a assaults",player,255,255,0);
}
else ClientMessage("You have already selected the "Assault"",player,255,255,0);
}
I basically created arrays to store the player data if they are selecting assaults/scount or any antitanks. Now to make the command "leave" || "left" you have to stand on your legs.
@KAKAN, he was basically asking, that how to get a message if the player have already selected a pacific men, job or whatever he says, so he can't use that command until he leave that particular men,job or whatever! you can understand by my command even.

Xmair

@[TBS]Destroyer , this can be improved.
function onScriptLoad ( )
{
work <- array ( GetMaxPlayers ( ) , "" );
}

function onPlayerCommand ( i_player , command , arguments )
{
local player = i_player , cmd = command.tolower( ), text = arguments;
if ( cmd == "job" )
{
text = text.tolower( );
if ( !text ) MessagePlayer("/job [ Assault / Scout / AntiTank ]" , player);
else if ( text == "assault" )
{
if ( work [ player.ID ] != "assault" )
{
player.Disarm( );
player.SetWeapon( 17 , 40 );
player.SetWeapon( 12 , 7 );
player.SetWeapon( 121 , 250 );
work [ player.ID ] = "assault";
MessagePlayer( "[#00FFF7]You're an assault trooper now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You're already " + work [ player.ID ] + "!" , player);
}
else if ( text == "scout" )
{
if ( work [ player.ID ] != "scout" )
{
player.Disarm( );
player.SetWeapon( 17 , 40 );
player.SetWeapon( 12 , 7 );
player.SetWeapon( 28 , 25 );
work [ player.ID ] = "scout";
MessagePlayer("[#00FFF7]You're a scout trooper now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You're already " + work [ player.ID ] + "!" , player);
}
else if ( text == "antitank" )
{
if ( work [ player.ID ] != "antitank" )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(111,10);
work [ player.ID ] = "antitank";
MessagePlayer("[#00FFF7]You are an anti tanker now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You are already " + work [ player.ID ] + "!" , player);
}
else MessagePlayer( "/job [ Assault / Scout / AntiTank ]" , player );
}
}

function onPlayerPart ( player , reason )
{
work [ player.ID ] = "";
}
Untested.

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

FarisDon

#4
Quote from: Xmair on Feb 21, 2016, 09:23 AM@[TBS]Destroyer , this can be improved.
function onScriptLoad ( )
{
work <- array ( GetMaxPlayers ( ) , "" );
}

function onPlayerCommand ( i_player , command , arguments )
{
local player = i_player , cmd = command.tolower( ), text = arguments;
if ( cmd == "job" )
{
text = text.tolower( );
if ( !text ) MessagePlayer("/job [ Assault / Scout / AntiTank ]" , player);
else if ( text == "assault" )
{
if ( work [ player.ID ] != "assault" )
{
player.Disarm( );
player.SetWeapon( 17 , 40 );
player.SetWeapon( 12 , 7 );
player.SetWeapon( 121 , 250 );
work [ player.ID ] = "assault";
MessagePlayer( "[#00FFF7]You're an assault trooper now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You're already " + work [ player.ID ] + "!" , player);
}
else if ( text == "scout" )
{
if ( work [ player.ID ] != "scout" )
{
player.Disarm( );
player.SetWeapon( 17 , 40 );
player.SetWeapon( 12 , 7 );
player.SetWeapon( 28 , 25 );
work [ player.ID ] = "scout";
MessagePlayer("[#00FFF7]You're a scout trooper now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You're already " + work [ player.ID ] + "!" , player);
}
else if ( text == "antitank" )
{
if ( work [ player.ID ] != "antitank" )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(111,10);
work [ player.ID ] = "antitank";
MessagePlayer("[#00FFF7]You are an anti tanker now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You are already " + work [ player.ID ] + "!" , player);
}
else MessagePlayer( "/job [ Assault / Scout / AntiTank ]" , player );
}
}

function onPlayerPart ( player , reason )
{
work [ player.ID ] = "";
}
Untested.
Sure, it could be, no doubt, but I really hate making the Cmds, for those ._. who just say I want, but the reason why I made this command, so like this cause, I guess he is too newbish to understand codes like that. my provided code could be more short like this
else if ( cmd== "assault")
{
if ( assaults[player.ID] != 1 )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(121,250);
MessagePlayer("[#00FFF7]You Are A assault Man Now",player);
player.IsFrozen = false;
assaults[player.ID] = 1;
}
else ClientMessage("You have already selected the "Assault"",player,255,255,0);
}
else if ( cmd== "scount")
{
if ( scouts[player.ID] != 1  )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(28,25);
MessagePlayer("[#00FFF7]You Are A Sniper Man Now",player);
player.IsFrozen = false;
scouts[player.ID] = 1;
}
ClientMessage("You have already selected the Scout",player,255,255,0);
}
else if ( cmd== "antitank")
{
if ( antitanks[player.ID] != 1 )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(111,10);
MessagePlayer("[#00FFF7]You Are A AntiTanker Now",player);
antitanks[player.ID] = 1;
}
else ClientMessage("You have already selected the Anti-Tank",player,255,255,0);
}
but the reason why i didn't made it like yours, or it short to make his understanding better anyway, I seriously don't know how to explain; however, i didn't also seen him saying about job or anyway that's why i made it the way he provided the code.
P.S: - Well we can just say that everybody have their own algorithm.

Xmair

Quote from: [TBS]Destroyer on Feb 21, 2016, 09:27 AM
Quote from: Xmair on Feb 21, 2016, 09:23 AM@[TBS]Destroyer , this can be improved.
function onScriptLoad ( )
{
work <- array ( GetMaxPlayers ( ) , "" );
}

function onPlayerCommand ( i_player , command , arguments )
{
local player = i_player , cmd = command.tolower( ), text = arguments;
if ( cmd == "job" )
{
text = text.tolower( );
if ( !text ) MessagePlayer("/job [ Assault / Scout / AntiTank ]" , player);
else if ( text == "assault" )
{
if ( work [ player.ID ] != "assault" )
{
player.Disarm( );
player.SetWeapon( 17 , 40 );
player.SetWeapon( 12 , 7 );
player.SetWeapon( 121 , 250 );
work [ player.ID ] = "assault";
MessagePlayer( "[#00FFF7]You're an assault trooper now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You're already " + work [ player.ID ] + "!" , player);
}
else if ( text == "scout" )
{
if ( work [ player.ID ] != "scout" )
{
player.Disarm( );
player.SetWeapon( 17 , 40 );
player.SetWeapon( 12 , 7 );
player.SetWeapon( 28 , 25 );
work [ player.ID ] = "scout";
MessagePlayer("[#00FFF7]You're a scout trooper now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You're already " + work [ player.ID ] + "!" , player);
}
else if ( text == "antitank" )
{
if ( work [ player.ID ] != "antitank" )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(111,10);
work [ player.ID ] = "antitank";
MessagePlayer("[#00FFF7]You are an anti tanker now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You are already " + work [ player.ID ] + "!" , player);
}
else MessagePlayer( "/job [ Assault / Scout / AntiTank ]" , player );
}
}

function onPlayerPart ( player , reason )
{
work [ player.ID ] = "";
}
Untested.
Sure, it could be, no doubt, but I really hate making the Cmds, for those ._. who just say I want, but the reason why I made this command, so like this cause, I guess he is too newbish to understand codes like that. my provided code could be more short like this
else if ( cmd== "assault")
{
if ( assaults[player.ID] != 1 )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(121,250);
MessagePlayer("[#00FFF7]You Are A assault Man Now",player);
player.IsFrozen = false;
assaults[player.ID] = 1;
}
else ClientMessage("You have already selected the "Assault"",player,255,255,0);
}
else if ( cmd== "scount")
{
if ( scouts[player.ID] != 1  )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(28,25);
MessagePlayer("[#00FFF7]You Are A Sniper Man Now",player);
player.IsFrozen = false;
scouts[player.ID] = 1;
}
ClientMessage("You have already selected the Scout",player,255,255,0);
}
else if ( cmd== "antitank")
{
if ( antitanks[player.ID] != 1 )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(111,10);
MessagePlayer("[#00FFF7]You Are A AntiTanker Now",player);
antitanks[player.ID] = 1;
}
else ClientMessage("You have already selected the Anti-Tank",player,255,255,0);
}
but the reason why i didn't made it like yours, or it short to make his understanding better anyway, I seriously don't know how to explain; however, i didn't also seen him saying about job or anyway that's why i made it the way he provided the code.
P.S: - Well we can just say that everybody have their own algorithm.
The command you just made now will give you a error 'expression expected'. else ClientMessage("You have already selected the "Assault"",player,255,255,0);

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

FarisDon

#6
Quote from: Xmair on Feb 21, 2016, 10:50 AM
Quote from: [TBS]Destroyer on Feb 21, 2016, 09:27 AM
Quote from: Xmair on Feb 21, 2016, 09:23 AM@[TBS]Destroyer , this can be improved.
function onScriptLoad ( )
{
work <- array ( GetMaxPlayers ( ) , "" );
}

function onPlayerCommand ( i_player , command , arguments )
{
local player = i_player , cmd = command.tolower( ), text = arguments;
if ( cmd == "job" )
{
text = text.tolower( );
if ( !text ) MessagePlayer("/job [ Assault / Scout / AntiTank ]" , player);
else if ( text == "assault" )
{
if ( work [ player.ID ] != "assault" )
{
player.Disarm( );
player.SetWeapon( 17 , 40 );
player.SetWeapon( 12 , 7 );
player.SetWeapon( 121 , 250 );
work [ player.ID ] = "assault";
MessagePlayer( "[#00FFF7]You're an assault trooper now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You're already " + work [ player.ID ] + "!" , player);
}
else if ( text == "scout" )
{
if ( work [ player.ID ] != "scout" )
{
player.Disarm( );
player.SetWeapon( 17 , 40 );
player.SetWeapon( 12 , 7 );
player.SetWeapon( 28 , 25 );
work [ player.ID ] = "scout";
MessagePlayer("[#00FFF7]You're a scout trooper now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You're already " + work [ player.ID ] + "!" , player);
}
else if ( text == "antitank" )
{
if ( work [ player.ID ] != "antitank" )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(111,10);
work [ player.ID ] = "antitank";
MessagePlayer("[#00FFF7]You are an anti tanker now!",player);
player.IsFrozen = false;
}
else MessagePlayer("You are already " + work [ player.ID ] + "!" , player);
}
else MessagePlayer( "/job [ Assault / Scout / AntiTank ]" , player );
}
}

function onPlayerPart ( player , reason )
{
work [ player.ID ] = "";
}
Untested.
Sure, it could be, no doubt, but I really hate making the Cmds, for those ._. who just say I want, but the reason why I made this command, so like this cause, I guess he is too newbish to understand codes like that. my provided code could be more short like this
else if ( cmd== "assault")
{
if ( assaults[player.ID] != 1 )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(121,250);
MessagePlayer("[#00FFF7]You Are A assault Man Now",player);
player.IsFrozen = false;
assaults[player.ID] = 1;
}
else ClientMessage("You have already selected the "Assault"",player,255,255,0);
}
else if ( cmd== "scount")
{
if ( scouts[player.ID] != 1  )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(28,25);
MessagePlayer("[#00FFF7]You Are A Sniper Man Now",player);
player.IsFrozen = false;
scouts[player.ID] = 1;
}
ClientMessage("You have already selected the Scout",player,255,255,0);
}
else if ( cmd== "antitank")
{
if ( antitanks[player.ID] != 1 )
{
player.Disarm();
player.SetWeapon(17,40);
player.SetWeapon(12,7);
player.SetWeapon(111,10);
MessagePlayer("[#00FFF7]You Are A AntiTanker Now",player);
antitanks[player.ID] = 1;
}
else ClientMessage("You have already selected the Anti-Tank",player,255,255,0);
}
but the reason why i didn't made it like yours, or it short to make his understanding better anyway, I seriously don't know how to explain; however, i didn't also seen him saying about job or anyway that's why i made it the way he provided the code.
P.S: - Well we can just say that everybody have their own algorithm.
The command you just made now will give you a error 'expression expected'. else ClientMessage("You have already selected the "Assault"",player,255,255,0);
Sorry, I didn't tested the code; however, I tested it right now, and worked fine! but maybe you have putted the code wrong, or simply change "Assault" to Assault that's it.

Cena

ok thanx i will test this cmd ty.
Want To Meet Me Come #Cena At Lunet