Jump to content

ZCMD + STRCMP - in acelasi script


RaZVaN ^ xD

Recommended Posts

ZCMD + STRCMP

V-ati gandit sa va actualizati vechiul script cu peste 500 de comenzi si sa-l treceti pe ZCMD, insa nu aveti destul timp sa modificati toate comenzile? Puteti modifica doar cateva comenzi, restul ramanand pe strcmp. Uitati cum trebuie sa procedati:

In primul rand, includeti libraria "zcmd" in script-ul dvs.:

#include <zcmd>
Cautati in script-ul dvs. callback-ul "OnPlayerCommandText":
public OnPlayerCommandText ( playerid, cmdtext [ ] )
In acest moment, il modificati in "OnPlayerCommandPerformed" si adaugati un ultim parametru, "success":
public OnPlayerCommandPerformed ( playerid, cmdtext [ ] , success )
Explicatie: In momentul in care ZCMD executa o comanda, "cheama" callback-ul OnPlayerCommandPerformed() cu parametrul "success = 1" daca acea comanda este ZCMD, sau "success = 0" daca acea comanda NU este ZCMD. Tot odata, va trebui sa adaugati urmatoarea clauza la OnPlayerCommandPerformed ( ):
if ( success ) return 1;
Explicatie: Daca, comanda executata este ZCMD, nu trebuie sa ne legam de ea, deoarece ne intereseaza comenzile non-ZCMD. Daca totul este corect, callback-ul ar trebui sa arate in felul urmator:
public OnPlayerCommandPerformed ( playerid, cmdtext [ ], success )
{
	if ( success ) return 1; // Daca, comanda executata este ZCMD, nu se intampla nimic

	if ( !strcmp ( cmdtext, "/test", true, 5 ) ) // Verifica daca, comanda executata este "/test"
	{
	    SendClientMessage ( playerid, -1, "Test!" );
	    return 1; // Comanda a fost procesata
	}

	if ( !strcmp ( cmdtext, "/test2", true, 6 ) ) // Verifica daca, comanda executata este "/test2"
	{
	    SendClientMessage ( playerid, -1, "Test2!" );
	    return 1; // Comanda a fost procesata
	}

	return 0; // In cazul in care comanda nu se gaseste in script ( indiferent daca e ZCMD sau alt procesor de comenzi, trimite mesajul "SERVER: Unknown command."
}

Y!M: [email protected] ( nu este ID pt. help-center )

Link to comment
Share on other sites

Join the conversation

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

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