24.07.2011, 13:00
Actually i am noob in scripting but i want to learn so i have planed to make simple roleplay now iam stuck in first step
i want to save stats in file i have code but i cant set it in each other if you do for me then i will learn much by seeing code.
i want to put stats in this register system its works fine
Register system:
Stats like that i want i found this by searching in ******
STATS:
but i want these stats in enum system please make it for me so i will learn.
i want to save stats in file i have code but i cant set it in each other if you do for me then i will learn much by seeing code.
i want to put stats in this register system its works fine
Register system:
pawn Код:
#include <a_samp>
#include <YSI\y_ini>
#include <dudb>
#define PATH "/Users/%s.ini"
#define PLAYER_MUST_REGISTER
#define REGISTERED_MONEY 5000
#define white 0xFFFFFFA
#define red 0xFF0000AA
#define lime 0x00FF00FF
#define yellow 0xFFFF00FF
#define DIALOG_REGISTER 999
#define DIALOG_LOGIN 998
#pragma unused ret_memcpy
enum iDetails {
Pass,
Cash,
Score
};
new pInfo[MAX_PLAYERS][iDetails];
#if defined AUTOLOGIN
new pIP[MAX_PLAYERS][16];
#endif
new pLogged[MAX_PLAYERS];
stock PlayerPath(playerid) {
new iStr[256],name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format(iStr,sizeof(iStr),PATH,name);
return iStr;
}
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
public OnGameModeExit()
{
return 1;
}
forward UserDataLoad_data(playerid,name[],value[]);
public UserDataLoad_data(playerid,name[],value[]) {
INI_Int("Pass",pInfo[playerid][Pass]);
#if defined AUTOLOGIN
INI_String("IP",pIP[playerid],16);
#endif
INI_Int("Cash",pInfo[playerid][Cash]);
INI_Int("Score",pInfo[playerid][Score]);
return 1;
}
public OnPlayerConnect(playerid)
{
pLogged[playerid] = 0;
#if defined AUTOLOGIN
new tmpIP[16];
GetPlayerIp(playerid,tmpIP,sizeof(tmpIP));
#endif
if(fexist(PlayerPath(playerid))) {
INI_ParseFile(PlayerPath(playerid), "UserDataLoad_%s", .bExtra = true, .extra = playerid);
#if defined AUTOLOGIN
if(strcmp(tmpIP,pIP[playerid],true) == 0) {
pLogged[playerid] = 1;
SetPlayerScore(playerid,pInfo[playerid][Score]);
GivePlayerMoney(playerid,pInfo[playerid][Cash]);
SendClientMessage(playerid,lime,"You've been auto-logged in. [IP match]");
return 1;
}
#endif
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Please enter your password below.","Login","Leave");
} else {
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please register by entering a password below.","Register","Leave");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(pLogged[playerid] == 1) {
new INI:iFile = INI_Open(PlayerPath(playerid));
INI_SetTag(iFile,"data");
INI_WriteInt(iFile,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(iFile,"Score",GetPlayerScore(playerid));
INI_Close(iFile);
}
pLogged[playerid] = 0;
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
if(pLogged[playerid] == 0) return SendClientMessage(playerid,yellow,"You must register or login before spawning!");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER) {
if(!response) Kick(playerid);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please enter a password.","Register","Leave");
new INI:iFile = INI_Open(PlayerPath(playerid));
INI_SetTag(iFile,"data");
INI_WriteInt(iFile,"Pass",udb_hash(inputtext));
#if defined AUTOLOGIN
INI_WriteString(iFile,"IP",pIP[playerid]);
#endif
INI_WriteInt(iFile,"Cash",REGISTERED_MONEY);
INI_WriteInt(iFile,"Score",0);
INI_Close(iFile);
pLogged[playerid] = 1;
new iStr[128];
format(iStr,sizeof(iStr),"You've successfully registered with the password \"%s\".",inputtext);
SendClientMessage(playerid,yellow,iStr);
return 1;
}
if(dialogid == DIALOG_LOGIN) {
if(!response) Kick(playerid);
new iStr[128],gTries;
if(gTries == 0) gTries = 1;
if(gTries == 3) {
new pName[30];
GetPlayerName(playerid,pName,sizeof(pName));
format(iStr,sizeof(iStr),"%s has been kicked for exceeding login tries.",pName);
SendClientMessageToAll(red,iStr);
return Kick(playerid);
}
if(!strlen(inputtext)) {
format(iStr,sizeof(iStr),"Please enter your password. Tries: %i/3",gTries);
return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",iStr,"Login","Leave");
}
if(udb_hash(inputtext) == pInfo[playerid][Pass]) {
pLogged[playerid] = 1;
SendClientMessage(playerid,lime,"You've successfully logged in.");
SetPlayerScore(playerid,pInfo[playerid][Score]);
GivePlayerMoney(playerid,pInfo[playerid][Cash]);
} else {
format(iStr,sizeof(iStr),"Incorrect password. Tries: %i/3",gTries);
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register",iStr,"Login","Leave");
gTries++;
return 1;
}
return 1;
}
return 1;
}
STATS:
pawn Код:
new level = PlayerInfo[targetid][pLevel];
new exp = PlayerInfo[targetid][pExp];
new nxtlevel = PlayerInfo[targetid][pLevel]+1;
new expamount = nxtlevel*levelexp;
new age = PlayerInfo[targetid][pAge];
new account = PlayerInfo[targetid][pAccount];
new ptime = PlayerInfo[targetid][pConnectTime];
new adminlevel = PlayerInfo[targetid][pAdmin];
if(adminlevel == 1338) { adminlevel = 1338; }
new pnumber = PlayerInfo[targetid][pPnumber];
new numtime = PlayerInfo[targetid][pCelltime];
new drugs = PlayerInfo[targetid][pDrugs];
new mats = PlayerInfo[targetid][pMats];
new carkey = PlayerInfo[targetid][pCarkey];
new carkey2 = PlayerInfo[targetid][pCarkey2];
new carkey3 = PlayerInfo[targetid][pCarkey3];
new rank = PlayerInfo[targetid][pRank];
new intir = GetPlayerInterior(targetid);
new virworld = GetPlayerVirtualWorld(targetid);
new local = PlayerInfo[targetid][pLocal];
new housekey = PlayerInfo[targetid][pHousekey];
new bizkey = PlayerInfo[targetid][pPbiskey];
new crimes = PlayerInfo[targetid][pCrimes];
new arrests = PlayerInfo[targetid][pArrested];
new freq = PlayerInfo[targetid][pWalkieFreq];
new name[MAX_PLAYER_NAME];
GetPlayerName(targetid, name, sizeof(name));
GiveNameSpace(name);
new coordsstring[256];
format(coordsstring, sizeof(coordsstring),"____________________| %s |____________________",name);
SendClientMessage(playerid, COLOR_YELLOW5,coordsstring);
format(coordsstring, sizeof(coordsstring), "[Account]: Level:[%d] DonateRank:[%s] Respect:[%d/%d] Age:[%d] Cash:[$%d] Bank:[$%d]", level,drank,exp,expamount,age,cash, account);
SendClientMessage(playerid, COLOR_LIGHTYELLOW5,coordsstring);
format(coordsstring, sizeof(coordsstring), "[General]: PlayingHours:[335] AdminLevel:[0] Job:[None] Job2:[None] WalkieFreq:[%d]",ptime,adminlevel,jtext,jtext2,freq);
SendClientMessage(playerid, COLOR_LIGHTYELLOW5,coordsstring);
if(PlayerInfo[targetid][pArrested] > 0)
{
format(coordsstring, sizeof(coordsstring), "[Criminal Record]: CrimesCommited:[%d] TimesArrested:[%d]", crimes,arrests);
SendClientMessage(playerid, COLOR_LIGHTYELLOW5,coordsstring);