SA-MP Forums Archive
[Tutorial] Simple Commands+Explain - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Simple Commands+Explain (/showthread.php?tid=298080)



Simple Commands+Explain - noder51 - 19.11.2011

i know that there was many spams on this but anyway i will try to explain.
pawn Код:
// lets try a simple command like heal
if(strcmp, "/heal", cmd, true, 10) == 0)
 SetPlayerHealth(playerid, 100); // so what is this thing? set player heal? what does it mean? it means that when player command /heal its setting hes hp 100
// so if you want to do that command it will look like that:
if(strcmp, "/heal", cmd, true, 10) == 0)
    {
         SetPlayerHealth(playerid, 100); // Do you see the set player health? we explaind it up there :)
         return 1;
    }
// now do think how do we do /kill? so its very easy! just copy the whole heal command and on the playerid, 100 you
// replace the 100 with 0 and the /heal with kill. easy right?
// got it?
// now lets do some other commads.
// here is a command that if player wants a kick, he will get if for sure :).
}
    if (strcmp("/kickme", cmdtext, true, 10) == 0) {
        {SendClientMessage(playerid, 0x33FF33AA, "you wanted a kick and got it :D");
Kick(playerid);return 1;}
}
// now you want pepole to see those commands right? very simple!
if (strcmp("/commands", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, 0xFFBB00,"Commands: /kickme /heal ");
return 1;
}
// sendclinetmessage? what the hell is that?
// it means that it sends the player (playerid) what that you wrote there!
well i dont have time to add more but i will try to add more and explain more......
hope that it will help new scriptrs...
noder51
or as my scripting name Ninjaa
thanks for looking at this


Re: Simple Commands+Explain - SmiT - 19.11.2011

Perhaps you could also explain under what callback those commands should go. Another thing - I don't see the part where you have declared the variable "cmd" so probably the user who follows this tutorial will get an error telling him the "cmd" symbol is undefined - I suggest you ident your code better.

pawn Код:
if (strcmp("/kickme", cmdtext, true, 10) == 0) {
        {SendClientMessage(playerid, 0x33FF33AA, "you wanted a kick and got it :D");
Kick(playerid);return 1;}
}
Why are you using two blocks since 1 is enough? -

pawn Код:
if ( strcmp ( "/kickme", cmdtext, true, 10 ) == 0 ) {
        SendClientMessage( playerid, 0x33FF33AA, "you wanted a kick and got it :D" );
        Kick(playerid); return 1;
    }



Re: Simple Commands+Explain - noder51 - 19.11.2011

lol you edit


Re: Simple Commands+Explain - SmiT - 19.11.2011

What are you talking about? Also, why would you teach new people creating those "simple" commands using strcmp which is old and slow rather then using a faster method?

Quote:
Originally Posted by noder51
Посмотреть сообщение
well i dont have time to add more but i will try to add more and explain more......
Well, if you don't have time why did you created this thread now when you could "add" more and "explain" more in your free time? I suggest you to read How to write a tutorial.


Re: Simple Commands+Explain - noder51 - 19.11.2011

i told you its my first tut.....