Jump to content

[6]Cum sa faci o comanda complexa STRCMP


Recommended Posts

Este continuare tutorialului 5 deci va rog sa fiti foarte atent deoarecem vom folosi functia STRTOK

Sa zicem ca vreti sa trimiteti unui jucator un mesaj. Uitati cum vom proceda

public OnPlayerCommandText(playerid, cmdtext[])
    new cmd[30];
    new idx;
    cmd = strtok(cmdtext, idx);

    if(strcmp(cmd, "/sayhello", true) == 0)
        new tmp[30];
        //introducem id-ul in variabila tmp
        tmp = strtok(cmdtext, idx);
        if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /sayhello [playerid]");// vom verifica daca a scris ceva

        // convertim tmp in intreg cu ajutorul lui strval (este esential)
        // iar apoi il punem in variabila incaunjucator 
        new incaunjucator = strval(tmp);

            SendClientMessage(incaunjucator , -1, "Tutorial");
        return 1;
    return 0;

Iar regula cu return 1; return 0; se aplica din nou




Link to comment
Share on other sites

  • 2 months later...
  • 2 weeks later...

Nu te supara,dar am o intrebare.

De ce incurajezi strcmp si strtok in loc de zcmd si sscanf.

Zcmd si sscanf proceseaza mult mai rapid.

In fine,tutorialele astea vor fi de ajutor multora :D


Adevarat :D Dar e si mai usor zic eu :D

+1 pt Tutorial



Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.