24.03.2010, 04:26
ok, i got my /register and /login account using Dini, and i want it to create an account with a CJ skin, and when someone changes their skin they can do /update and it updates their account to when they log in, it logs them in with that skin. heres what i got.
Код:
if(strcmp(cmd, "/register", true) == 0) { new name[MAX_PLAYER_NAME]; new IP[16]; tmp = strtok(cmdtext, idx); GetPlayerName(playerid, name, sizeof(name)); GetPlayerIp(playerid,IP,sizeof(IP)); if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /register [password]"); format(file,sizeof(file),"%s.ini",name); if(!fexist(file)) { dini_Create(file); dini_IntSet(file, "Password", udb_hash(tmp)); dini_IntSet(file,"AdminLevel", 0); dini_IntSet(file,"Cash", 0); dini_IntSet(file,"Skin", 0); dini_IntSet(file,"Score", 0); SendClientMessage(playerid, COLOR_LIME, "[System]: Account Created!"); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); GetPlayerName(playerid, name, sizeof(name)); printf("%s has registered a account!", name); } else { SendClientMessage(playerid, COLOR_RED, " Account Already Found In Database"); PlayerPlaySound(playerid,1057,0.0,0.0,0.0); } return 1; } if(strcmp(cmd, "/login", true) == 0) { new PlayerName[24]; tmp = strtok(cmdtext, idx); if(strlen(tmp) == 0) return SendClientMessage(playerid, COLOR_SG, "USAGE: /login [password]"); new name[MAX_PLAYER_NAME]; if(IsLogged[playerid] == 1) { SendClientMessage(playerid, COLOR_RED, "You already are logged in!"); return 1; } else { GetPlayerName(playerid, name, sizeof(name)); format(file,sizeof(file),"%s.ini",name); if(fexist(file)) { tmp2 = dini_Get(file, "Password"); if(udb_hash(tmp) != strval(tmp2)) { SendClientMessage(playerid, COLOR_RED, "Login Failed!"); GetPlayerName(playerid, PlayerName, sizeof(PlayerName)); printf("%s has failed to login", name); } else { IsLogged[playerid] = 1; SetPlayerMoney(playerid, dini_Int(file, "Cash")); SetPlayerScore(playerid, dini_Int(file, "Score")); SetPlayerSkin(playerid, dini_Int(file, "Skin")); PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel"); SendClientMessage(playerid, COLOR_LIME, "[System]: Logged in!"); } } } return 1; } if(!strcmp(cmdtext,"/update",true)) { if(IsLogged[playerid] == 1) { GetPlayerMoney(playerid, dini_Int(file, "Cash")); GetPlayerScore(playerid, dini_Int(file, "Score")); GetPlayerSkin(playerid, dini_Int(file, "Skin")); SendClientMessage(playerid,COLOR_LIME,"Account Updated"); if(IsLogged[playerid] == 0) { SendClientMessage(playerid,COLOR_LIME,"You arnt logged in or registered!"); return 1; } } }