Vice City: Multiplayer

VC:MP Discussion => Support => Topic started by: ahmedzead on Feb 07, 2017, 09:36 AM

Title: how to add cmds ??
Post by: ahmedzead on Feb 07, 2017, 09:36 AM
hi all im new in vcmp programming so can any one tell me about add cmds or admin cmds ??? plz :) :)
Title: Re: how to add cmds ??
Post by: luchgox on Apr 29, 2017, 07:56 AM
function onPlayerCommand( player, cmd, text )
{
if (cmd == "yourcmd")
 {
 MessagePlayer(">> "+player.Name+"  your cmd" ,player);
 }
Title: Re: how to add cmds ??
Post by: ! on Apr 29, 2017, 08:04 AM
Scripting stuff (http://forum.vc-mp.org/?board=10.0)
&
QuoteStick to play.
Title: Re: how to add cmds ??
Post by: kennedyarz on Apr 29, 2017, 11:29 AM
Quote from: ahmedzead on Feb 07, 2017, 09:36 AMhi all im new in vcmp programming so can any one tell me about add cmds or admin cmds ??? plz :) :)

función onPlayerCommand (jugador, cmd, texto)
{
if(cmd=="1")
{
Message(player.Name+" : <>")
}
else if(cmd=="2")
{
MessagePlayer(player.Name+": <>",player)
}
else if(cmd=="3")
{
PrivMessage(player,""+player.Name+": <>.")
}
else MessagePlayer("Invalid Commad",player)
return 1;
}
}
Title: Re: how to add cmds ??
Post by: EK.IceFlake on Apr 29, 2017, 12:22 PM
Quote from: kennedyarz on Apr 29, 2017, 11:29 AM
Quote from: ahmedzead on Feb 07, 2017, 09:36 AMhi all im new in vcmp programming so can any one tell me about add cmds or admin cmds ??? plz :) :)

función onPlayerCommand (jugador, cmd, texto)
{
if(cmd=="1")
{
Message(player.Name+" : <>")
}
else if(cmd=="2")
{
MessagePlayer(player.Name+": <>",player)
}
else if(cmd=="3")
{
PrivMessage(player,""+player.Name+": <>.")
}
else MessagePlayer("Invalid Commad",player)
return 1;
}
}
An error has occurred [expected '}']
Title: Re: how to add cmds ??
Post by: ! on Apr 29, 2017, 02:16 PM
Quote from: kennedyarz on Apr 29, 2017, 11:29 AM.......
MessagePlayer(player.Name+": <>",player)
......
dafaq?
How he came in this world.
Title: Re: how to add cmds ??
Post by: KrlozZ... on Apr 29, 2017, 06:15 PM
Quote from: kennedyarz on Apr 29, 2017, 11:29 AM
Quote from: ahmedzead on Feb 07, 2017, 09:36 AMhi all im new in vcmp programming so can any one tell me about add cmds or admin cmds ??? plz :) :)

función onPlayerCommand (jugador, cmd, texto)
{
if(cmd=="1")
{
Message(player.Name+" : I'm gay")
}
else if(cmd=="2")
{
MessagePlayer(player.Name+": My family is gay",player)
}
else if(cmd=="3")
{
PrivMessage(player,""+player.Name+": Stick to play.")
}
else MessagePlayer("Invalid Commad",player)
return 1;
}
}

jugador ._. no player
Title: Re: how to add cmds ??
Post by: Shadow on Apr 29, 2017, 07:23 PM
I know I'm probably speaking to an army of 10 year olds but you were at the same level of his a few years back (or even months). Why not care to explain instead of hitting him with such replies? Also, when was insulting people for no reason allowed in the rules?
Title: Re: how to add cmds ??
Post by: Castagna on Apr 29, 2017, 10:57 PM
Quote from: Shadow on Apr 29, 2017, 07:23 PMI know I'm probably speaking to an army of 10 year olds but you were at the same level of his a few years back (or even months). Why not care to explain instead of hitting him with such replies? Also, when was insulting people for no reason allowed in the rules?
That's why a certain people got banned lately ::)

Welcome to the official VC:MP forums and scripting center.

Quote from: ahmedzead on Feb 07, 2017, 09:36 AMhi all im new in vcmp programming so can any one tell me about add cmds or admin cmds ??? plz :) :)

Scripts are usually made of fuctions and events:

http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Events

http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions

I guess this will be good enough to start with. Command codes go to onPlayerCommand event (http://wiki.vc-mp.org/wiki/OnPlayerCommand)

A quick command example taken from the Wiki:

function onPlayerCommand( player, cmd, text )
{
    if ( cmd == "heal" )
   {
           if ( player.Health == 100 ) PrivMessage( player, "You have the health to maximum.");
          else
           {
              PrivMessage( player, "You healed successfully.");
              player.Health = 100;
           }
    }
}   

You will notice a mix between logic, maths and particular Squirrel syntax which (in case you don't read tutorials or manuals), you will get used to with practicing.
Title: Re: how to add cmds ??
Post by: KAKAN on Apr 30, 2017, 03:34 AM
Quote from: Castagna on Apr 29, 2017, 10:57 PMYou will notice a mix between logic, maths and particular Squirrel syntax which (in case you don't read tutorials or manuals), you will get used to with practicing.
In case you're too lazy to google, http://www.squirrel-lang.org/#documentation
or
http://www.squirrel-lang.org/squirreldoc/reference/index.html