[Help] Basic Question
#1

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
Reply
#2

A tutorial:

https://sampwiki.blast.hk/wiki/Strtok
Reply
#3

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
Reply
#4

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.
Reply
#5

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
Reply
#6

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.
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)