[Tutorial] Simple Roleplay Commands. /me and /do
#1

Introduction:

Hello SA-MP Community!
My Name Is Taha Asif aka Nathan Sykes and today i am gonna show you how to create RP Commands With ZCMD!
I WIll Explain ou Guys My Best.


Tutorial:


Now Let Me Explain You Guys. /me and /do Are Commands To Show Actions. In Heavy Roleplay Server's It Is Very Important To Be Good With RP'ing.

I Am Going To Use ZCMD. You Can ****** It.

* TahaAsif12 Command:


Код:
CMD:me(playerid, params[]) //We use this to tell the server which cmd is being used
{ //opening bracket
	if(isnull(params)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /me [action]"); //this gives the player some hint how to use this cmd
	new string[128]; //string which will be used later
	format(string, sizeof(string), "* %s %s", GetPlayerNameEx(playerid), params); // here is the string used. This formats the player actions of what he types
        SendClientMessageToAll(-1, string); //sends the cleint message
	return 1; //return of our CMD
} //closing bracket
Explaination Is In The Code Box!

Now For /do:

Код:
CMD:do(playerid, params[]) //same as above. tells the client which CMD is used
{ //opening bracket
	if(isnull(params)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /do [action]"); //tells the player how to use this CMD
	else if(strlen(params) >= 100) return SendClientMessageEx(playerid, COLOR_GREY, "The specified message must not be longer than 99 characters in length."); //checks if the player writes more than 99 words
	new string[100]; //string to be used in format
	format(string, sizeof(string), "* %s (( %s ))", params, GetPlayerNameEx(playerid)); //formats the action of the player
                SendClientMessageToAll(-1, string); //sends the cleint message
	return 1; //return of our cmd
} //closing bracket
I Apologize If Something Is Not Explained Good.

I Am Also Not A Pro Scripter But I Just Wanted To Share My Little Knowledge With You.

Remember To Leave A Rep If You Like It!
Reply
#2

Why do you have to declare an array 128 slots big for /do? If you are limiting the players' usage to 99 words, use an array which has 100 slots because the other 28 slots are not touched, generally waste. ;

pawn Код:
new string[100];
Explain each function and parameters, don't be too lazy for it. And please clean up your thread, it's too classic.
Reply
#3

Quote:
Originally Posted by Sublime
Посмотреть сообщение
Why do you have to declare an array 128 slots big? If you are limiting the players' usage to 99 words, use an array which has 100 slots because the other 28 slots are not touched, generally waste. ;

pawn Код:
new string[100];
OOPS i forgot :P.

i will edit it.
Anyway thanks for the tip.
Reply
#4

The funniest thing is that, it doesn't show to result lol. do
pawn Код:
SendClientMessageToAll(-1, string);
EDIT: i wish u can tell us about the GetPlayerNameEx function and a function we can use as an alterative.
Reply
#5

Quote:
Originally Posted by newbie scripter
Посмотреть сообщение
The funniest thing is that, it doesn't show to result lol. do
pawn Код:
SendClientMessageToAll(-1, string);
LOL. Sry Dude As I Am Not So Good Pawno

And this is my second tut so i apologize
Reply
#6

nvm even i was more dumber xD.
Reply
#7

Quote:
Originally Posted by newbie scripter
Посмотреть сообщение
nvm even i was more dumber xD.
HEHE. Anyways thanks for the rep repped back
Reply
#8

Don't post tutorials if you don't know how to, easy. Post FilterScripts and if you make mistakes because you're a beginner; nobody will care then.
Reply
#9

Quote:
Originally Posted by Kindred
Посмотреть сообщение
Don't post tutorials if you don't know how to, easy. Post FilterScripts and if you make mistakes because you're a beginner; nobody will care then.
I Think You Didn't Read The Post. i Said I Am not good but i just want to share the knowledge i learned
Reply
#10

Quote:
Originally Posted by Sublime
Посмотреть сообщение
Why do you have to declare an array 128 slots big for /do? If you are limiting the players' usage to 99 words, use an array which has 100 slots because the other 28 slots are not touched, generally waste. ;

pawn Код:
new string[100];
Explain each function and parameters, don't be too lazy for it. And please clean up your thread, it's too classic.
Not at all. If you look, the total potential length of "string" is 132 (given a 99-character string and a 24-character name). "string" holds the entire message, not just the entered text.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)