SA-MP Forums Archive (https://sampforum.blast.hk/index.
php)
/ SA-MP Scripting and Plugins (forumdisplay.php?fid=8) / Scripting Help (forumdisplay.php?fid=12)
/ Tutorials (forumdisplay.php?fid=70&page=51)
[Tutorial] Making basic Threaded Mode (showthread.php?mode=threaded&tid=324389&pid=1720853#pid1720853)
commands [ZCMD]
09.03.2012, 11:37 #1 (showthread.php?tid=324389&pid=1720853#pid1720853)
Okay. This is my first tutorial and I'm still a noob so I'd appreciate help but criticism
(member.php? will NOT be appreciated.
action=profile&
Gangs_Rocks Getting started
(https://samp
action=profile
Big Clucker
First of all, You need a SA-MP server kit, SA-MP, ZCMD installed. Firstly, you open
your script and go to the place where you mostly do your commands made with
Posts: 114 ZCMD's. If you're new to this, All you gotta do is scroll down where the script ends
Threads: 27 and there is where you start your cmds with you're using ZCMD. For strcmp, Go to:
Joined: Feb
2012 public OnPlayerCommandText.
Reputation: 0
(reputation.php?
Okay, Now i'll start the serious shit
uid=153355)
Some functions that are important
Okay, now before we start, You all may think that you want something like you type
/dm and boom, you get teleported to a location and you give the player some guns
and set his health, armour and stuff like that.
We'll be using the follow Callbacks below:
SetPlayerPos(playerid, X, Y, Z) // XYZ = co-ordinates. Debug guide in sampwiki will
help.
GivePlayerWeapon(playerid, Weaponid, ammo) //For giving weapons
SetPlayerHealth(playerid, AMOUNTOFHEALTH) // For setting health
SetPlayerArmour(playerid, AMOUNTOFARMOUR) // For setting armour
SetPlayerSkin(playerid, SKINID) // For setting Skin ID's
SetPlayerInterior(playerid, Interiorid) // MOST IMPORTANT if you're making
teleport command for interior
ResetPlayerWeapons(playerid) //Disarms the player
SendAllClientMessage(HEXCOLOR, "Message")
Starting the serious shit
Okay, what you saw was getting ready. Now we're going to start the serious shit.
First, we start with a very basic healme and armourme command.
Quote:
CMD:healme(playerid,params[])
That line basically defines the usage of the command. Note: This is case sensitive.
Healme won't work but healme will.
Now:
Quote:
{
//Code here
After the CMD: line, we always do the { bracket in order to define the starting of
what our command will actually do
Okay, So we'll be using the SetPlayerHeatlh callback now as this is the healme
command.
Quote:
CMD:healme(playerid,params[])
{
SetPlayerHeatlh(playerid, 100); // This sets the health of the player to 100
SendClientMessage(playerid, 0xFF8000FF, "You have been healed! "); // Sends the player message
[OPTIONAL]Now you may want to add a price to your healme command. This is
quite easy and we'll be using GivePlayerMoney callback for this.
Quote:
CMD:healme(playerid,params[])
{
SetPlayerHeatlh(playerid, 100);
GivePlayerMoney(playerid, -500); // -500 means it will take 500$ frmo the player. You can change
this.
SendClientMessage(playerid, 0xFF8000FF, "You have been healed for 500$! ");
Now you think this is done. But no no, wait. Before we complete a command, we
must add a } bracket to define that we closed the command. And in the end, add
return 1;
Quote:
CMD:healme(playerid,params[])
{
SendClientMessage(playerid, 0x33CCFFAA, " Health restored for 500$! ");
SetPlayerHealth(playerid, 100);
GivePlayerMoney(playerid, -500);
return 1;
}
Voila! That's our code for /healme. Quite the same way,just copy that code,now just
change SetPlayerHealth to SetPlayerArmour, change CMD:healme to
CMD:armourme and There it is! Your healme and armourme commands are ready
Try it out ingame right now!
Questions you may have regarding this:
Q:I want to make a shortcode for this command. How do I do that?
Ans:You want armourme and ame to do the same thing. Now instead of copying and
renaming the same code, we can add this line:
Quote:
CMD:ame(playerid, params[]) return cmd_armourme(playerid, params);
I'll explain now:
Quote:
CMD: (Shortenedcmd)(playerid,params[]) return cmd_(orignal cmd name)(playerid,params[])
First, you just name the shortened command. Then, you add return
cmd_orignalcmdname. Orignal cmd name = Cmd name you used for the big
command. Like healme or armourme.
Q: How many callbacks can a command hold?
Ans: Unlimited until and unless they disturb each others usage.
Okay, now an example of a teleporting command:
In this command, one basically teleports the player to grovestreet, sets the player
skin to a grove street gang member, sends the player a message welcoming him to
grove st. and sends a message to all players alerting that the player has joined
/grovestreet.
Quote:
CMD:grovestreet(playerid,params[])
{
SetPlayerPos(playerid, 2493.9133, -1682.3986, 13.3382);
SendClientMessage(playerid, 0xFF8000FF, "Welcome to grove street!");
SetPlayerSkin(playerid, 107);
new pname[MAX_PLAYER_NAME], string[50 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s has joined the grove gang area! Join him and have fun at
/grovestreet", pname);
SendClientMessageToAll(-1, string);
return 1;
}
CMD:gs(playerid, params[]) return cmd_grovestreet(playerid, params);
You must have noticed that I've used a string here. A string is used when the
information that has to be submitted has to be filled at the time of the usage of the
command. It's cool and a bit hard to understand though. This string gets the player
name on spot and sends the message to all players. And no, I'm not explaining how
to use a string since I'm teaching how to make commands, not strings and how to
script etc.
And another example of making commands with string is this:
Quote:
CMD:myinfo( playerid, params[ ] )
{
new p_IP[ 16 ], sz_msg[ 128 ];
GetPlayerIp( playerid, p_IP, 16 );
format( sz_msg, sizeof( sz_msg ), "IP: (%s) Skin: (%d) Score: (%d) Money: (%d) Weapon: (%d)
Ammo: (%d) Ping: (%d)", p_IP, GetPlayerSkin( playerid ), GetPlayerScore( playerid ),
GetPlayerMoney( playerid ), GetPlayerWeapon( playerid ), GetPlayerAmmo( playerid ),
GetPlayerPing( playerid ) );
SendClientMessage( playerid, -1, sz_msg );
return 1;
}
In this command, you basically give the player some basic info about himself in-
game. His IP is stated and instead of a string, I've used the format.
Now, I'll tell you how to make animations work through commands:
We'll use ApplyAnimation callback here. Find it on SA-MP wiki if you need help
regarding it.
ApplyAnimation(playerid, animlib[], animname[], Float:fDelta, loop, lockx, locky,
freeze, time, forcesync)
That's how we gotta use it. Okay, Now we gotta know one definite thing: If we make
a command that starts an animation we gotta make a command that stops it/them
since some are unstoppable. Later, I'll show you how to make a command
/stopanim command.
Quote:
CMD:drunk(playerid,params[])
{
ApplyAnimation(playerid,"PED","WALK_DRUNK",4.1,1,1 ,1,1,1,1);
SendClientMessage(playerid,0xFFFF00AA,"Be careful! You're drunk! Use /stopanim to stop this
animation" );
return 1;
}
So first we do the ApplyAnimation, the anim library is PED and the anim name is
WALK_DRUNK. Capitals are important, note that. There's nothing much to explain
since its very simple. If you need the list of anim libs and their names, you can
check them here: https://sampwiki.blast.hk/wiki/Animations
(https://sampwiki.blast.hk/wiki/Animations). Headings = Library names and
options = Anim names.
Now you got a /drunk command which helps you walk drunk. But what if you wanna
return to normal? That creates a problem. No no no, No need to apply your special
old tricks to stop some problem. We'll do a code for this. We have a callback called
ClearAnimations which we will use now:
Quote:
CMD topanim(playerid,params[])
{
ClearAnimations(playerid);
SendClientMessage(playerid, 0xFFFF00AA, "Animations cleared!");
return 1;
}
Clean and simple, We just use 2 callbacks. ClearAnimations to do the work and
SendClientMessage to inform that player. It's easy creating commands. All you
gotta do is use some important callbacks.
This is my first tutorial and I began scripting around 2-3 weeks ago. I hope this
helps
Find (search.php?action=finduser&uid=153355) Reply (newreply.php?tid=324389&replyto=1720853)
19.03.2012, 18:09 #2 (showthread.php?tid=324389&pid=1741485#pid1741485)
very COOL
(member.php?
action=profile&
Alexy_Dramon
(https://samp
action=profile
Big Clucker
Posts: 126
Threads: 22
Joined: Feb
2012
Reputation: 0
(reputation.php?
uid=156191)
Find (search.php?action=finduser&uid=156191) Reply (newreply.php?tid=324389&replyto=1741485)
19.03.2012, 18:44 #3 (showthread.php?tid=324389&pid=1741575#pid1741575)
(member.php? ResetPlayerWeapons(playerid) //Disarms the player - WRONG
action=profile& ResetPlayerWeapons(playerid) //Resets Players Weapons.
BetaLaxx
(https://samp
action=profile
Big Clucker
Posts: 125
Threads: 26
Joined: Sep
2011
Reputation: 0
(reputation.php?
uid=139179)
Find (search.php?action=finduser&uid=139179) Reply (newreply.php?tid=324389&replyto=1741575)
19.03.2012, 19:22 #4 (showthread.php?tid=324389&pid=1741670#pid1741670)
Quote:
(member.php? Originally Posted by BetaLaxx
action=profile& (showthread.php?pid=1741575#pid1741575)
ResetPlayerWeapons(playerid) //Disarms the player - WRONG
ResetPlayerWeapons(playerid) //Resets Players Weapons.
Max_Coldhear
(https://samp
pawn Code:
action=profile
forward DisarmPlayer(playerid);
Gangsta public DisarmPlayer(playerid)
{
return ResetPlayerWeapons(playerid); // Disarms player
Posts: 667 }
Threads: 11
Joined: Dec
2011
Happy now? Disarms player.
Reputation: 0
(reputation.php? He can call it disarming as it removes the weapons anyway.
uid=147462)
Find (search.php?action=finduser&uid=147462) Reply (newreply.php?tid=324389&replyto=1741670)
01.07.2013, 10:15 #5 (showthread.php?tid=324389&pid=2593904#pid2593904)
hi i tried to make the cmds /healme but it gave
(member.php? by adding this line
action=profile& Quote:
mubashir //---------------------------------
(https://samp CMD:"healme(playerid,params[])
{
action=profile SendClientMessage(playerid, 0x33CCFFAA, " Health restored for 500$! ");
SetPlayerHealth(playerid, 100);
GivePlayerMoney(playerid, -500);
Little Clucker
return 1;
}
//----------------------------------
Posts: 37
Threads: 6
Joined: May
2013 but it gave me a error
Reputation: 0
(reputation.php? Quote:
uid=202075)
C:\games\GTA SanAndreas\SeRveR SaMp\gamemodes\letstestyou.pwn(334) : error 037: invalid
string (possibly non-terminated string)
C:\games\GTA SanAndreas\SeRveR SaMp\gamemodes\letstestyou.pwn(339) : error 010: invalid
function or declaration
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
when i compiled
Find (search.php?action=finduser&uid=202075) Reply (newreply.php?tid=324389&replyto=2593904)
01.07.2013, 10:20 #6 (showthread.php?tid=324389&pid=2593911#pid2593911)
well i fixed that part but now it says
(member.php? Quote:
action=profile&
C:\games\GTA SanAndreas\SeRveR SaMp\gamemodes\letstestyou.pwn(334) : error 001: expected
mubashir token: "-string end-", but found "-identifier-"
C:\games\GTA SanAndreas\SeRveR SaMp\gamemodes\letstestyou.pwn(339) : error 010: invalid
(https://samp function or declaration
action=profile Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
Little Clucker 2 Errors.
Posts: 37
Threads: 6
Joined: May
2013
Reputation: 0
(reputation.php?
uid=202075)
Find (search.php?action=finduser&uid=202075) Reply (newreply.php?tid=324389&replyto=2593911)
04.07.2013, 10:37 #7 (showthread.php?tid=324389&pid=2597731#pid2597731)
Quote:
(member.php?
Originally Posted by mubashir
action=profile& (showthread.php?pid=2593911#pid2593911)
well i fixed that part but now it says
Raaf
(https://samp Please past the full code here.
action=profile
Little Clucker
Posts: 34
Threads: 5
Joined: Dec
2012
Reputation: 0
(reputation.php?
uid=189678)
Find (search.php?action=finduser&uid=189678) Reply (newreply.php?tid=324389&replyto=2597731)
06.07.2013, 06:06 #8 (showthread.php?tid=324389&pid=2600411#pid2600411)
nice tutorial explained better rep+
(member.php?
action=profile&
Team_PRO
(https://samp
action=profile
High-roller
Posts: 1,839
Threads: 136
Joined: Aug
2012
Reputation: 0
(reputation.php?
uid=175134)
Find (search.php?action=finduser&uid=175134) Reply (newreply.php?tid=324389&replyto=2600411)
06.07.2013, 21:10 #9 (showthread.php?tid=324389&pid=2601364#pid2601364)
Quote:
(member.php? Originally Posted by mubashir
action=profile& (showthread.php?pid=2593911#pid2593911)
well i fixed that part but now it says
Aerotactics
(https://samp You probably are missing a semicolon ";".
action=profile
High-roller
Posts: 1,079
Threads: 199
Joined: Jun
2013
Reputation: 0
(reputation.php?
uid=205103)
Find (search.php?action=finduser&uid=205103) Reply (newreply.php?tid=324389&replyto=2601364)
« Next Oldest (showthread.php?tid=324389&action=nextoldest) | Next Newest (showthread.php?
tid=324389&action=nextnewest) »
Enter Keywords Search Thread
View a Printable Version (printthread.php?tid=324389)
Forum Jump: ---- Tutorials Go
Users browsing this thread: 1 Guest(s)
SA-MP Forums Archive (https://sampforum.blast.hk/index.php)
/ SA-MP Scripting and Plugins (forumdisplay.php?fid=8) / Scripting Help (forumdisplay.php?fid=12)
/ Tutorials (forumdisplay.php?fid=70&page=51)
English (American) Go
Powered By MyBB (http://www.mybb.com). Crafted by EREE (https://eree.in) and Android BG (https://forum.androidbg.com/). Also powered by
blast.hk (https://www.blast.hk/)