SavePlayerGuns
#1

Hello, I was working a thing that would save player guns when he dies because most of the time when players die before they respawn they reconnect so they wouldnt lose any guns, but it doesnt work.

Код:
public OnPlayerDeath(playerid, killerid, reason)
{

    ResetPlayerWeapons(playerid);
    SavePlayerGuns(playerid);
Код:
forward SavePlayerGuns(playerid);
Код:
public SavePlayerGuns(playerid)
{
	new name[MAX_PLAYER_NAME],file[128];
	GetPlayerName(playerid,name,sizeof(name));
	format(file,sizeof(file),"saves/user/%s.ini",name);
	if(!fexist(file)) return;
	new weps[2][12];

	for (new tmp=0; tmp<12; tmp++) GetPlayerWeaponData(playerid,tmp,weps[0][tmp],weps[1][tmp]);
	dini_IntSet(file,"Ginklas0",weps[0][0]); dini_IntSet(file,"Ammo0",weps[1][0]);
	dini_IntSet(file,"Ginklas1",weps[0][1]); dini_IntSet(file,"Ammo1",weps[1][1]);
	dini_IntSet(file,"Ginklas2",weps[0][2]); dini_IntSet(file,"Ammo2",weps[1][2]);
	dini_IntSet(file,"Ginklas3",weps[0][3]); dini_IntSet(file,"Ammo3",weps[1][3]);
	dini_IntSet(file,"Ginklas4",weps[0][4]); dini_IntSet(file,"Ammo4",weps[1][4]);
	dini_IntSet(file,"Ginklas5",weps[0][5]); dini_IntSet(file,"Ammo5",weps[1][5]);
	dini_IntSet(file,"Ginklas6",weps[0][6]); dini_IntSet(file,"Ammo6",weps[1][6]);
	dini_IntSet(file,"Ginklas7",weps[0][7]); dini_IntSet(file,"Ammo7",weps[1][7]);
	dini_IntSet(file,"Ginklas8",weps[0][8]); dini_IntSet(file,"Ammo8",weps[1][8]);
	dini_IntSet(file,"Ginklas9",weps[0][9]); dini_IntSet(file,"Ammo9",weps[1][9]);
	dini_IntSet(file,"Ginklas10",weps[0][10]); dini_IntSet(file,"Ammo10",weps[1][10]);
	dini_IntSet(file,"Ginklas11",weps[0][11]); dini_IntSet(file,"Ammo11",weps[1][11]);
	}
Reply
#2

Bump
Reply
#3

You are removing the guns before saving them, duh, use your logic.
Reply
#4

Everything is fine i want to remove the guns and save them, because if i dont save them the player will have them after reconnection. Im removing the guns because i want to be sure that the player doesnt have any and then i try to save them before the player disconnects.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)