how to add cmds ??

Started by ahmedzead, Feb 07, 2017, 09:36 AM

Previous topic - Next topic

ahmedzead

hi all im new in vcmp programming so can any one tell me about add cmds or admin cmds ??? plz :) :)

luchgox

function onPlayerCommand( player, cmd, text )
{
if (cmd == "yourcmd")
 {
 MessagePlayer(">> "+player.Name+"  your cmd" ,player);
 }
Strength does not come from wining.Your struggles develop your strengths.

!


Discord: zeus#5155

kennedyarz

#3
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;
}
}

EK.IceFlake

#4
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 '}']

!

#5
Quote from: kennedyarz on Apr 29, 2017, 11:29 AM.......
MessagePlayer(player.Name+": <>",player)
......
dafaq?
How he came in this world.

Discord: zeus#5155

KrlozZ...

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

Shadow

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?
QuotePS:is trash is ur home language??

Castagna

#8
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.

KAKAN

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
oh no