Jump to content

[6]Cum sa faci o comanda complexa STRCMP


Recommended Posts

Posted

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);

        if(IsPlayerConnected(incaunjucator))
        {
            SendClientMessage(incaunjucator , -1, "Tutorial");
        }
        return 1;
    }
    return 0;
}

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

 

1859311972_BANNER-GIREADAcopy-min.thumb.png.48e5e420ae2185dce5b244965a1d2601.png

 

  • 2 months later...
Posted

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

Bafta.

Massari e curva mea

  • 2 weeks later...
Posted

Am pus in caz ca incepatori vor lucra pe un GodFather si vor sa faca o comanda

 

1859311972_BANNER-GIREADAcopy-min.thumb.png.48e5e420ae2185dce5b244965a1d2601.png

 

Posted

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

Bafta.

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

+1 pt Tutorial

 

logo.png

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.