12.11.2009, 10:49
how to make this commands dcmd ?
Код:
public OnPlayerCommandText(playerid, cmdtext[]) { new cmd[256],tmp[256], tmp2[256], idx, string[256]; cmd = strtok(cmdtext, idx); if(strcmp(cmd, "/register", true) == 0) { tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /register (password)"); } else { if (!dini_Exists(udb_encode(pInfo[playerid][name]))) { dini_Create(udb_encode(pInfo[playerid][name])); dini_IntSet(udb_encode(pInfo[playerid][name]), "password", udb_hash(tmp)); OnPlayerRegister(playerid); format(string, sizeof(string), "Account %s aangemaakt! Je kunt nu inloggen met het wachtwoord: %s.", pInfo[playerid][name], tmp); SendClientMessage(playerid, COLOR_YELLOW, string); } else { format(string, sizeof(string), "%s already registered.", pInfo[playerid][name],tmp); SendClientMessage(playerid, COLOR_RED, string); } } return 1; } if(strcmp(cmd, "/login", true) == 0) { if(pInfo[playerid][logged] == 1) { SendClientMessage(playerid, COLOR_RED, "Je bent al ingelogd"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_YELLOW, "Gebruik: /login (wachtwoord)"); } else { if (dini_Exists(udb_encode(pInfo[playerid][name]))) { tmp2 = dini_Get(udb_encode(pInfo[playerid][name]), "password"); if (udb_hash(tmp) != strval(tmp2)) { SendClientMessage(playerid, COLOR_RED, "Verkeerd wachtwoord!."); } else { OnPlayerLogin(playerid); format(string, sizeof(string), "%s, je bent nu ingelogd. Level: %d, Money: %d, Score: %d", pInfo[playerid][name], pInfo[playerid][level], pInfo[playerid][money], pInfo[playerid][score]); SendClientMessage(playerid, COLOR_GREEN, string); } } else { format(string, sizeof(string), "Het account %s, bestaat nog niet. Typ /register [wachtwoord] om een account te maken.", pInfo[playerid][name]); SendClientMessage(playerid, COLOR_RED, string); } } return 1; } return 0; }