Saving Data's Problem
#1

Quote:

if(strcmp(cmd, "/haduty", true) == 0)
{
if(IsPlayerConnected(playerid))
{
giveplayerid = playerid;
new amount1 , amount2 , amount3;
new playernames[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][pMember] != 8 ) return SendClientMessage(playerid, COLOR_GREY, "Shoma dastresi kafi baraye anjame in kar ra nadarid!");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Dastoor: /Haduty [on/off] [New Name] [NewLevel] [Newleveljob] [Newphonenumber] ");
return 1;
}
if(strcmp("off", tmp, true, strlen(tmp)) == 0)
{
new playernamess[MAX_PLAYER_NAME];
strmid(playernamess, PlayerInfo[playerid][HadutyName], 0, strlen(PlayerInfo[playerid][HadutyName]), MAX_PLAYER_NAME);
SetPlayerName(playerid, playernamess);
PlayerInfo[playerid][pJob] = PlayerInfo[playerid][HadutyJob];
PlayerInfo[playerid][pDetSkill] = PlayerInfo[playerid][HadutySkill];
PlayerInfo[playerid][pPnumber] = PlayerInfo[playerid][HadutyPhone];
PlayerInfo[playerid][pLevel] = PlayerInfo[playerid][HadutyLevel];
GetRPN(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "%s /Haduty Ra Gheyre Faal Kard", sendername);
PlayerInfo[playerid][Haduty] = 0;
ClearHadutyName(playerid);
PlayerInfo[playerid][HadutySkill] = 0;
PlayerInfo[playerid][HadutyPhone] = 0;
PlayerInfo[playerid][HadutyLevel] = 0;
PlayerInfo[playerid][HadutyJob] = 0;
HadutyLog(string);
return 1;
}
else if(strcmp("on", tmp, true, strlen(tmp)) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Dastoor: /Haduty [on/off] [New Name] [NewLevel] [Newleveljob] [Newphonenumber] ");
return 1;
}
format(string, sizeof(string), "Users/%s.ini", tmp);
GetPlayerName(giveplayerid, playernames, sizeof(playernames));
strmid(PlayerInfo[playerid][HadutyName], playernames, 0, strlen(playernames), MAX_PLAYER_NAME);
if(fexist(string))
{
SendClientMessage(playerid, COLOR_GRAD1, " That name is already registered.");
return 1;
}
new playername[MAX_PLAYER_NAME];
new log[MAX_PLAYER_NAME];
GetPlayerName(giveplayerid, playername, sizeof(playername));
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
SetPlayerName(giveplayerid, tmp);
GetPlayerName(giveplayerid, log, sizeof(log));
format(string, sizeof(string), "Users/%s.ini", giveplayer);
fremove(string);
if(doesAccountExist(playername)) // If it doesn't get removed, blank the file with write io and check its length when a player attempts to authenticate (it'll be 0)
{
new File: BlankTheFile = fopen(string, io_write);
SendClientMessage(playerid, COLOR_GRAD2, "The old account couldn't be removed completely (it's been blanked for future use).");
fclose(BlankTheFile);
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Dastoor: /Haduty [on/off] [New Name] [NewLevel] [Newleveljob] [Newphonenumber]");
return 1;
}
amount1 = strvalEx(tmp);
PlayerInfo[playerid][HadutyLevel] = PlayerInfo[playerid][pLevel];
PlayerInfo[playerid][pLevel] = amount1;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Dastoor: /Haduty [on/off] [New Name] [NewLevel] [Newleveljob] [Newphonenumber]");
return 1;
}
amount2 = strvalEx(tmp);
PlayerInfo[playerid][HadutyJob] = PlayerInfo[playerid][pJob];
PlayerInfo[playerid][HadutySkill] = PlayerInfo[playerid][pDetSkill];
switch(amount2)
{
case 1:
PlayerInfo[playerid][pDetSkill] = 100;
case 2:
PlayerInfo[playerid][pDetSkill] = 200;
case 3:
PlayerInfo[playerid][pDetSkill] = 300;
case 4:
PlayerInfo[playerid][pDetSkill] = 400;
case 5:
PlayerInfo[playerid][pDetSkill] = 500;
}
PlayerInfo[playerid][pJob] = 1;
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "Dastoor: /Haduty [on/off] [New Name] [NewLevel] [Newleveljob] [Newphonenumber]");
return 1;
}
amount3 = strvalEx(tmp);
PlayerInfo[playerid][HadutyPhone] = PlayerInfo[playerid][pPnumber];
PlayerInfo[playerid][pPnumber] = amount3;
format(string, sizeof(string), "%s Used /Haduty and Changed Name to %s And Level %d And Detective Level %d And Phone number %d", PlayerInfo[playerid][HadutyName], log, PlayerInfo[playerid][pLevel] , PlayerInfo[playerid][pDetSkill] ,PlayerInfo[playerid][pPnumber] );
HadutyLog(string);
format(string, sizeof(string), "esme ghabli: %s level ghabli: %d job ghabli: %d skill ghabl:%d phone:%d", PlayerInfo[playerid][HadutyName],PlayerInfo[playerid][HadutyLevel],PlayerInfo[playerid][HadutyJob] ,PlayerInfo[playerid][HadutySkill],PlayerInfo[playerid][HadutyPhone] );
HadutyLog(string);
PlayerInfo[playerid][Haduty] = 1;
}
}
return 1;
}

Hello Everyone
it is my Command for Haduty
this command will change player name and level and job and joblevel and phone number and save them in a file
but when i use /haduty off
i have problem with name
for example:
my name was "Test"
after using /haduty , i changed it to "Gholombe"
But When I Wrote /haduty off
my name will be "T"
Reply


Messages In This Thread
Saving Data's Problem - by Masoud - 22.04.2015, 20:30

Forum Jump:


Users browsing this thread: 1 Guest(s)