[Tutorial] How to create a simple announce cmd[sscanf|| Zcmd]
#1

How to create a simple Announce command


Introduction

This is a simple tutorial which helps you to learn how to create simple announce commands using Zcmd and Sscanf2
I apologise now itself if this tutorial isnt well explained/wrong because Im posting this using mobile.
Also this is my first tutorial.
ZCMD:It is a command processor which allows to create command in a simple way and execute it faster.
Download:forum.sa-mp.com/showthread.php?t=91354

Sscanf2:Here sscanf2 is used to input text to announce for all and also for easy scripting.
Download:forum.sa-mp.com/showthread.php?t=120356

Use

First lets include files which is needed to run the script.
Here we are going to use 3 includes.
a_samp[Needed for every script]
zcmd[For faster and simple command executing]
sscanf2[For inputing the text in an easy way.]

So,lets start with including files.
NOTE:a_samp is needed for every script,so you must start with a_samp include.
pawn Code:
#include <a_samp> //Included a_samp.
#include <zcmd> //Included zcmd.
#include <sscanf2> //Included sscanf2.
We've included the includes needed to run the script,now lets start making command.
Here's an example of command way in zcmd
pawn Code:
CMD:zcmdway(playerid,params[])
{
  //This is the command way of zcmd.
   //Here function.
Lets start creating our command under the includes.
pawn Code:
CMD:announce(playerid,params[])
{
//Zcmd command processor system. ^
   new text[60]; //Create a new variable to execute text via sscanf.[60]refers to its string length.
   if(sscanf(params, "s[60]",text)) //Here we are using "s" to output entered text.[60] is the string.
//And we've executed "text" variable here.
//By doing these,we have created a function to detect usage.
   return SendClientMessage(playerid, 0xFF0000, "Usage:/announce [text]");//Here we are adding a message how to use if  player doesnt inputs text.
   GameTextForAll(text,3000,3); //Here,we're using this to announce our text in GameText style.
//You can change the style of Gametext by changing the "3" at last.
//And the 3000 refers to time(milliseconds) of gametext to be displayed.
//GameTexts: wiki.sa-mp.com/wiki/GameTextForPlayer
   return 1; //We're returning the cmd here.
} //Closing brackets to end cmd.
Finalised Code
pawn Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

CMD:announce(playerid,params[])
{
  new text[60];
  if(sscanf(params,"s[60]",text))
  return SendClientMessage(playerid, 0xFF0000, "Usage:/announce [text]");
  GameTextForAll(text,3000,3);
  return 1;
}
Credits

a_samp by SAMP Team.
Zcmd by ZeeX.
Sscanf by ******.
Tutorial by [xB]Lordz.(me )

NOTE:If there is any error,mistake or problem,please post here.
Reply
#2

nice tutorial,well explaned.
Quote:

Zcmd cmd system. ^

command proccecor*
Reply
#3

Nice well explained.
Reply
#4

I love it, it even makes it awesome that you posted on my wall asking me if the command would work.
Reply
#5

Quote:
Originally Posted by Akira297
View Post
I love it, it even makes it awesome that you posted on my wall asking me if the command would work.
LOL,I aint having Pc and did it through mobile.
So i wasnt sure that this is correct or not.
Quote:
Originally Posted by TaLhA XIV
View Post
Nice well explained.
Thanks.
Quote:
Originally Posted by xkirill
View Post
nice tutorial,well explaned.

command proccecor*
Thanks and I'll chage it.
Reply
#6

Nice work! Lordz, you are really good man. nice explained +rep 1
Reply
#7

Quote:
Originally Posted by Akira297
View Post
I love it, it even makes it awesome that you posted on my wall asking me if the command would work.
I saw that, lawl.
Reply
#8

Quote:
Originally Posted by [xB]Lordz
View Post
Thanks and I'll chage it.
Quote:

//Zcmd command processor system. ^

remove the system.
and its ZCmd,
Z stands for Zeex and and cmd for command.
so its ZCmd or better zcmd (with no capital letters)
Reply
#9

Quote:
Originally Posted by xkirill
View Post
remove the system.
and its ZCmd,
Z stands for Zeex and and cmd for command.
so its ZCmd or better zcmd (with no capital letters)
No not this again...
It takes a lot of time to edit because of more texts used.
My E71 is lagging a lot while editing and got hanged.
Now switched off and switched on again.
I'll edit later...
Thx xkiril.
Reply
#10

Can I get more comments?
Reply
#11

pawn Code:
CMD:announce(playerid,params[])
{
if(isnull(params)) return SendClientMessage(playerid,-1,"USAGE:/announce [text]");
GameTextForAll(params,3000,3);
return 1;
}
You dont need sscanf for one parameter commands.
Reply
#12

Quote:
Originally Posted by C00K13M0N$73R
View Post
pawn Code:
CMD:announce(playerid,params[])
{
if(isnull(params)) return SendClientMessage(playerid,-1,"USAGE:/announce [text]");
GameTextForAll(params,3000,3);
return 1;
}
You dont need sscanf for one parameter commands.
For me,sscanf is more easier and better.
Btw you're right,here we dont need sscanf to do this,but while making a lot of commands(Eg:Adm cmds),sscanf will be more better.
Because while using sscanf,cmds which requires parameters can be easily created without any confusion or other problems etc
Reply
#13

Any more feedbacks?
Reply
#14

Good job writing this on a mobile is kinda difficult, but also you can make this without using sscanf too, the command is /announce [text], so you could just use the params[], parameter in zcmd, other then that nicely explained.
Reply
#15

Thank you Lexi'.
Reply
#16

Even if it's a simple tutorial,I like it because it uses cool features of SAMP coding,lik sscanf,zcmd,etc.If I saw a tutorial that uses strcmp,strtok,I'd probably kill myself.Good job .
Reply
#17

Nice tutorial, for people who can't work with zcmd(like me)
Reply
#18

Quote:
Originally Posted by Cjgogo
View Post
Even if it's a simple tutorial,I like it because it uses cool features of SAMP coding,lik sscanf,zcmd,etc.If I saw a tutorial that uses strcmp,strtok,I'd probably kill myself.Good job .
Yeah for some guys strcmp and strtok makes mad.
Where as ZCMD and YCMD and some other cmd processors are good to see+faster execution.

Quote:
Originally Posted by Smokkr
View Post
Nice tutorial, for people who can't work with zcmd(like me)
LOL thanks.
Reply
#19

good work bro!
Hope you become a good scripter!
Reply
#20

@ irfu ,
Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)