01.08.2017, 09:52
Hi!
In this post i'd like to help those who don't know about scripting or they are beginners and they do not know how to add commands and add any action in it, Well, It is very easy, Before that i'm going to introduce myself. I am a 15-16 years old programmer from Pakistan. I've studied PHP , Javascript from different sites, Because i really thought that coding language will also make scripting easy. Yes, that's true if you're alone and you have no teacher and i recommend you to learn Javascript , C or c++, Because you would have understood some commands and will get to know what coding is. So that'd make scripting easier, But if you don't know any coding language then don't worry because there's a teacher to help you out! . So Let's begin the tutorial.
Following is the example of adding command!
//Following command is used to show commands which you've added,
If you'll write /cmds then this will appear as:
That was easy, wasn't it?
So let's go forward to add any action in the command
Let's make a command to give person a gun.
Note: You should write "else if" because this will make a single action.
Like:
Well, Following command will just send a person message who writes that command
And following command will give weapon only
So, it is very easy to add command then other coding. isn't it?
Reply if you want more help then i'll help you out!
In this post i'd like to help those who don't know about scripting or they are beginners and they do not know how to add commands and add any action in it, Well, It is very easy, Before that i'm going to introduce myself. I am a 15-16 years old programmer from Pakistan. I've studied PHP , Javascript from different sites, Because i really thought that coding language will also make scripting easy. Yes, that's true if you're alone and you have no teacher and i recommend you to learn Javascript , C or c++, Because you would have understood some commands and will get to know what coding is. So that'd make scripting easier, But if you don't know any coding language then don't worry because there's a teacher to help you out! . So Let's begin the tutorial.
Following is the example of adding command!
Код:
public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/mycommand", cmdtext, true, 10) == 0) { // Do something here return 1; } return 0; }
Код:
if (strcmp(cmdtext,"/cmds") == 0) { SendClientMessage(playerid, 0xAA3333AA, "/kill , /get "); return 1; }
Код:
/kill , /get
That was easy, wasn't it?
So let's go forward to add any action in the command
Let's make a command to give person a gun.
Note: You should write "else if" because this will make a single action.
Like:
Код:
else if (strcmp("/molo", cmdtext, true, 10) == 0) { SendClientMessage(playerid, HexColorHere, "You have recieved some molotovs."); GivePlayerWeapon (playerid,18,15); return 1; }
Код:
SendClientMessage(playerid, HexColorHere, "You have recieved some molotovs.");
Код:
GivePlayerWeapon (playerid,weaponid,ammount);
Reply if you want more help then i'll help you out!