if(dialogid == 201) { if(!strlen(inputtext)) return ShowPlayerDialog(playerid,201,DIALOG_STYLE_INPUT,"Registration","ERROR: You did not enter a password.\nPlease enter a password to register this account!","Register","Cancel"); new playerfile[128], pname[MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, sizeof(pname)); format(playerfile, sizeof(playerfile), "EAdmin/Users/%s.ini",pname); if(dini_Exists(playerfile)) return SendClientMessage(playerid, red, "You are already registered!"); new playerip[20]; GetPlayerIp(playerid, playerip, sizeof(playerip)); dini_Create(playerfile); dini_IntSet(playerfile, "Password", udb_hash(inputtext)); dini_Set(playerfile, "Ip", playerip); dini_IntSet(playerfile, "Level", 0); dini_IntSet(playerfile, "Cash", 0); dini_IntSet(playerfile, "Score", 0); logged[playerid] = 1; SendClientMessage(playerid, yellow, "You have registered your account! You have also been logged in."); } if(dialogid == 200) { if(!strlen(inputtext)) return ShowPlayerDialog(playerid,200,DIALOG_STYLE_INPUT,"Login","ERROR: You did not enter a password.\nPlease enter a password to login to this account!","Login","Cancel"); new playerfile[100], pname[MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, sizeof(pname)); format(playerfile, sizeof(playerfile), "EAdmin/Users/%s.ini",pname); if(!dini_Exists(playerfile)) return SendClientMessage(playerid, red, "This account is not yet registered, please type /register."); new tmp[256]; tmp = dini_Get(playerfile, "Password"); if(udb_hash(inputtext) == strval(tmp)) { new playerip[20]; GetPlayerIp(playerid, playerip, sizeof(playerip)); level[playerid] = dini_Int(playerfile, "Level"); logged[playerid] = 1; dini_Set(playerfile, "Ip", playerip); GivePlayerMoney(playerid, dini_Int(playerfile, "Cash")); SetPlayerScore(playerid, dini_Int(playerfile, "Score")); logged[playerid] = 1; SendClientMessage(playerid, yellow, "You have logged in!"); } else return ShowPlayerDialog(playerid,200,DIALOG_STYLE_INPUT,"Login","ERROR: Invalid Password.\nPlease enter a password to login to this account!","Login","Cancel"); }
Hey pro scripter, if i pay you can you fix the problem i have in the topic above me?
|
public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(login, 5, cmdtext); dcmd(register, 8, cmdtext); return 1; } dcmd_login(playerid, params) { ShowPlayerDialog(playerid,201,DIALOG_STYLE_INPUT,"Registration",Please enter a password to register this account!","Register","Cancel"); return 1; } dcmd_register(playerid, params) { ShowPlayerDialog(playerid,200,DIALOG_STYLE_INPUT,"Login","Please enter a password to login to this account!","Login","Cancel"); return 1; }
CMD:gethere(playerid,params[])
{
new tmp[25],idx,targetid;
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
tmp = strtok(params, idx);
while(strlen(tmp) > 0)
{
targetid = ReturnUser(tmp);
if(IsPlayerConnected(targetid))
{
SetPlayerPos(targetid,x,y+1,z);
}
tmp = strtok(params,idx);
}
return 1;
}
strcmp is better when you have a command which has only one ( string ) parameter
and strtok is better when you have a command with an indeterminate number of parameters pawn Код:
|
CMD:gethere(playerid,params[])
{
new
Float:x,
Float:y,
Float:z,
iPlayer;
if(sscanf(params, "u", iPlayer))
return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /gethere [playerid/part of name]");
GetPlayerPos(playerid,x,y,z);
SetPlayerPos(targetid,x,y+1,z);
return 1;
}
I never said strcmp is better, learn to read.
I'm just saying that even if dcmd and zcmd is better, faster and more efficient, you shouldn't "force him" to use it. It still is optional, so by saying "use dcmd or zcmd" you're telling him that it won't work elseway. What if he's not familiar with zcmd or dcmd? What if he don't know how to use it? What if he's not smart enough (most likely) to learn zcmd or dcmd? I'm just saying. |
#include <zcmd>
CMD:register(playerid,params[])
{
if(isnull(params)) return SendClientMessage(playerid,yellow,"Registration","ERROR: You did not enter a password.");
new playerfile[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(playerfile, sizeof(playerfile), "EAdmin/Users/%s.ini",pname);
if(dini_Exists(playerfile)) return SendClientMessage(playerid, red, "You are already registered!");
new playerip[20];
GetPlayerIp(playerid, playerip, sizeof(playerip));
dini_Create(playerfile);
dini_IntSet(playerfile, "Password", udb_hash(inputtext));
dini_Set(playerfile, "Ip", playerip);
dini_IntSet(playerfile, "Level", 0);
dini_IntSet(playerfile, "Cash", 0);
dini_IntSet(playerfile, "Score", 0);
logged[playerid] = 1;
SendClientMessage(playerid, yellow, "You have registered your account! You have also been logged in.");
return 1;
}
CMD:login(playerid,params[])
{
if(isnull(params)) return SendClientMessage(playerid,yellow,"Login","ERROR: You did not enter a password.");
new playerfile[100], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(playerfile, sizeof(playerfile), "EAdmin/Users/%s.ini",pname);
if(!dini_Exists(playerfile)) return SendClientMessage(playerid, red, "This account is not yet registered, please type /register.");
new tmp[256];
tmp = dini_Get(playerfile, "Password");
if(udb_hash(inputtext) == strval(tmp))
{
new playerip[20];
GetPlayerIp(playerid, playerip, sizeof(playerip));
level[playerid] = dini_Int(playerfile, "Level");
logged[playerid] = 1;
dini_Set(playerfile, "Ip", playerip);
GivePlayerMoney(playerid, dini_Int(playerfile, "Cash"));
SetPlayerScore(playerid, dini_Int(playerfile, "Score"));
logged[playerid] = 1;
SendClientMessage(playerid, yellow, "You have logged in!");
} else {
SendClientMessage(playerid,yellow,"Login","ERROR: Invalid Password");
return 1;
}
return 1;
}