Making /vw (virtualworld) command using ZCMD and sscanf -
electrux - 22.07.2012
Hey guys i am creating a tutorial to make a command for virtual worlds using zcmd and sscanf.
First you will need zcmd and sscanf get them from here:
ZCMD:
ZCMD
sscanf:
sscanf
Now lets get started.
First we will use the includes
pawn Code:
#include <a_samp>
#include <sscanf>
#include <zcmd>
I dont think i will need to tell what it means.
Now lets start the main command
pawn Code:
CMD:vw(playerid,params[])
{
new virtualworld;
if(sscanf(params,"i",virtualworld)) return SendClientMessage(playerid,-1,"USAGE: /vw [id]");
else
{
new str[256];
SetPlayerVirtualWorld(playerid,virtualworld);
format(str,sizeof(str),"You are now in virtual world %d",virtualworld);
SendClientMessage(playerid,-1,str);
}
return 1;
}
Now lets see what have we done here.
pawn Code:
CMD:vw(playerid,params[])
{
here we are declaring/making and starting our command using ZCMD.
NOTE: commands starting like this are NOT in "OnPlayerCommandText" function.
In this we have declared a new variable ie virtualworld.
pawn Code:
if(sscanf(params,"i",virtualworld)) return SendClientMessage(playerid,-1,"USAGE: /vw [id]");
In this part we are seeing for the virtualworld id the player is giving after /vw command. If the player doesnt type the parameter he will recieve this message that he has to type a parameter.
pawn Code:
else
{
new str[256];
SetPlayerVirtualWorld(playerid,virtualworld);
format(str,sizeof(str),"You are now in virtual world %d",virtualworld);
SendClientMessage(playerid,-1,str);
}
If the player has specified a parameter it will go to the next part of code ie after else part this part sets the virtualworld of player by using SetPlayerVirtualWorld function.
We have also made a new variable str.
Here we are using format function because SendClientMessage does not support use of %d, %s etc.The format function is using str variable.
Then we are using SendClientMessage to tell the player that he is now in the virtualworld he specified as a parameter.
This tells the work of the code is over.
Please dont be harsh as this is my first post..
Also sorry for my bad grammar
Re: Making /vw (virtualworld) command using ZCMD and sscanf -
CoDeZ - 22.07.2012
Ehm sir , Wrong section
And please next time use
Re: Making /vw (virtualworld) command using ZCMD and sscanf -
JaKe Elite - 22.07.2012
Uhm sir.
You are in wrong section and please use [ pawn ] [ /pawn ] tags
Re: Making /vw (virtualworld) command using ZCMD and sscanf -
Kindred - 22.07.2012
Indeed.
3/10, considering you didn't use pawn tags, you barely explain the things (judging from me reading it for only a few seconds) and it just doesn't look neat.
Re: Making /vw (virtualworld) command using ZCMD and sscanf -
electrux - 22.07.2012
sorry people i didnt know the section i am new to samp forums
i will now remember to use pawn and / pawn tags. also i am using mobile to write so please sorry
Re: Making /vw (virtualworld) command using ZCMD and sscanf -
[MM]RoXoR[FS] - 22.07.2012
It should be here :
Tutorial's
Re: Making /vw (virtualworld) command using ZCMD and sscanf -
electrux - 22.07.2012
ok i will remember next time thanks for the advice though
Re: Making /vw (virtualworld) command using ZCMD and sscanf -
electrux - 22.07.2012
hey should i make this thread in tutorials??
Re: Making /vw (virtualworld) command using ZCMD and sscanf -
doreto - 22.07.2012
Quote:
Originally Posted by electrux
hey should i make this thread in tutorials??
|
NO AND DONT SPAMM EVERY 3 MIN GO READ THE RULES OR YOU WILL BE
BANNED
Re: Making /vw (virtualworld) command using ZCMD and sscanf -
electrux - 22.07.2012
ok ok sorryy wont do again