[Help] Basic Question - 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: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] Basic Question (
/showthread.php?tid=197630)
[Help] Basic Question -
rubygta - 09.12.2010
Hello there! I am a fresh scripter to Pawno, and I have been incresing my skills alot. There is one thing I cant seem to understand though.. This is probably a stupid question, but w/e.. I have seen ppl do this in tuts, but I dont really know why the different things is there, and what they do, so for example, I want to make an admin command that is /healplayer <ID>. How do I make this work, please try to explain, I like to understand what I am scripting, Thank you in advance
Re: [Help] Basic Question -
CyNiC - 09.12.2010
A tutorial:
https://sampwiki.blast.hk/wiki/Strtok
Re: [Help] Basic Question -
rubygta - 09.12.2010
Quote:
Originally Posted by cynic
|
Ye, that's the tut I saw, didn't really understand that =(, But thank you very much for your answer

I'll try to study it even closer, though.
EDIT: If any1 has an easier way or can make a quick tut for me here, I'd be happy for it
Re: [Help] Basic Question -
blackwave - 09.12.2010
TOP:
Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
cmdtext
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(heal,4,cmdtext); // Comand name before the amount of characters
return 0;
}
After all callbacks:
pawn Код:
dcmd_heal(playerid,params[])
{
new id; // ID which will be healed
id = strval(params);
SetPlayerHealth(id, 100.0);
SetPlayerArmour(id, 100.0);
return 1;
}
I just use dcmd, at all.
Re: [Help] Basic Question -
rubygta - 09.12.2010
Quote:
Originally Posted by blackwave
TOP:
Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
cmdtext
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(heal,4,cmdtext); // Comand name before the amount of characters return 0; }
After all callbacks:
pawn Код:
dcmd_heal(playerid,params[]) { new id; // ID which will be healed id = strval(params); SetPlayerHealth(id, 100.0); SetPlayerArmour(id, 100.0); return 1; }
I just use dcmd, at all.
|
Sorry, I don't use dcmd :/ Anyone got a code for strcmp ? With descriptions ?Thank you. btw thank you for your answer Blackwave
Re: [Help] Basic Question -
Hal - 09.12.2010
Read the wiki. Thats the best bet you have. Or look in other scripts that use strcmp, and see how they made it. DON'T copy and paste the cmd, just see how they made the cmdtext define the playerid.
Re: [Help] Basic Question -
Retardedwolf - 09.12.2010
Use ZCMD and sscanf.
pawn Код:
COMMAND:healplayer( playerid, params [ ] )
{
if ( IsPlayerAdmin ( playerid ) ) //Change to likings
{
new
tPlayer,
;
if ( sscanf ( params, "u", tPlayer ) ) return SendClientMessage ( playerid, 0xFFFFFFAA, "SYNTAX: `| /healplayer [ Target player or name ]`" );
else
{
SetPlayerHealth ( tPlayer, 100.0 );
}
}
return 1;
}
If you're new to scripting Pawn in SA:MP you should start using scripts that can help a lot such as using MySQL, zcmd, foreach, sscanf and a few others.