Quote:
Originally Posted by Matthew_Murdoch
Snoob, that gm u gave me, its missing a money system
|
well if u would look a bit more closer to that script ud see urself how to do X_X
change "writeinfo"
to
pawn Код:
writeinfo(playerid){
// This function is use to store curent player info in our file.
new PlaName[MAX_PLAYER_NAME],path[128]; //creating string for name and path
UserInfo[playerid][MONEY] = GetPlayerMoney(playerid);
GetPlayerName(playerid, PlaName, sizeof(PlaName));//store playername in PlaName
format(path, sizeof(path), "snoob/registered/%s", PlaName);// formating the path
new tmp[128], File:regfile = fopen(path,io_write);//needed variable...
format(tmp, sizeof(tmp),"%s\r\n%s\r\n%i\r\n%i\r\n%i\r\n",// formating the string...
UserInfo[playerid][PASSWORD], UserInfo[playerid][LASTIP],
UserInfo[playerid][LEVEL], UserInfo[playerid][KILL], UserInfo[playerid][DEATH],UserInfo[playerid][MONEY]);
then change "OnPlayerConnect"
to
pawn Код:
public OnPlayerConnect(playerid)
{
//////////////////////////////////////////
UserInfo[playerid][LEVEL] = 0;
UserInfo[playerid][KILL] = 0;
UserInfo[playerid][DEATH] = 0;
UserInfo[playerid][MUSTLOGIN] = 0;
UserInfo[playerid][MONEY] = 0;
// we reset the player info on connection.
//////////////////////////////////////////
if (IsPlayerRegistered(playerid)) { // if the player is registered
loadinfo(playerid); //load the player info
UserInfo[playerid][MUSTLOGIN] = 1; //this player will need to login before spawn
SendClientMessage(playerid, COLOR_TXT, "This name is registered, Please /login");//inform the player he need to login
}
else SendClientMessage(playerid, COLOR_TXT, "You can use /register to protect your name.");//inform the player he need to login
return 1;
}
then change enum info on line 6
to
pawn Код:
enum info { MUSTLOGIN, PASSWORD[30], LASTIP[30], LEVEL, KILL, DEATH, Float:RATIO, MONEY };//defines the UserInfos
Be happy i were bored^^
Have Fun
-Saiberfun
Edit:
Oh and change loadinfo
to
pawn Код:
loadinfo(playerid)
{
// this function is used to load the player ifo from the file
new PlaName[MAX_PLAYER_NAME],path[128]; //creating string for name and path
GetPlayerName(playerid, PlaName, sizeof(PlaName));//store playername in PlaName
format(path, sizeof(path), "snoob/registered/%s", PlaName);// formating the path
new tmpload[128], File:regfile; // needed var...
regfile = fopen(path,io_read); //opening file for reading
fread(regfile,UserInfo[playerid][PASSWORD],30); //reading first line(password) and store it to tmp.
strdel(UserInfo[playerid][PASSWORD],strlen(UserInfo[playerid][PASSWORD])-2,strlen(UserInfo[playerid][PASSWORD]));
fread(regfile,UserInfo[playerid][LASTIP],30); //reading second line(lastIP) and store it to tmp.
strdel(UserInfo[playerid][LASTIP],strlen(UserInfo[playerid][LASTIP])-2,strlen(UserInfo[playerid][LASTIP]));
fread(regfile,tmpload,sizeof(tmpload)); //reading third line(level)
UserInfo[playerid][LEVEL] = strval(tmpload);//storing the string value...
fread(regfile,tmpload,sizeof(tmpload)); //reading
UserInfo[playerid][KILL] = strval(tmpload);//storing
fread(regfile,tmpload,sizeof(tmpload)); //reading
UserInfo[playerid][DEATH] = strval(tmpload);//storing
fread(regfile,tmpload,sizeof(tmpload)); //reading
UserInfo[playerid][MONEY] = strval(tmpload);//storing
fclose(regfile);// closing the file.
ResetPlayerMoney(playerid);//resetting old money
GivePlayerMoney(playerid,UserInfo[playerid][MONEY]);//giving the saved money
return 1;//load complete we RETURN 1;
}