Weapon saving - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Weapon saving (
/showthread.php?tid=238483)
Weapon saving -
sim_sima - 11.03.2011
Hello guys.
Im makeing a gamemode. I have made a login/register system that is using Dini for stat saveing.
I want to make is save the players weapons when he disconnects, and give him the weapons again whenm he connects.
I have already done like this:
This is from "OnPlayerDisconnect"
pawn Код:
new weapons[13][2];
for(new i = 0; i < 13; i++)
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
dini_IntSet(file, "Weapons", weapons[i][0], weapons[i][1]);
(Those are line 107 - 110).
It gives me this error:
Код:
C:\Users\Simon\Desktop\samp server rpg\gamemodes\rpg-gm.pwn(110) : error 017: undefined symbol "i"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
Hope you guys can help me. Thank you.
Re: Weapon saving -
~Yoshi - 11.03.2011
pawn Код:
new weapons[13][2];
for(new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
dini_IntSet(file, "Weapons", weapons[i][0], weapons[i][1]);
}
Forgot the brackets?
Re: Weapon saving -
sim_sima - 11.03.2011
Quote:
Originally Posted by ~Yoshi
pawn Код:
new weapons[13][2]; for(new i = 0; i < 13; i++) { GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]); dini_IntSet(file, "Weapons", weapons[i][0], weapons[i][1]); }
Forgot the brackets?
|
Close, but one warning:
Код:
C:\Users\Simon\Desktop\samp server rpg\gamemodes\rpg-gm.pwn(111) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
Re: Weapon saving -
sim_sima - 11.03.2011
Here is line 111 btw:
pawn Код:
dini_IntSet(file, "Weapons", weapons[i][0], weapons[i][1]);
Re: Weapon saving -
Zh3r0 - 11.03.2011
Quote:
Originally Posted by sim_sima
Close, but one warning:
Код:
C:\Users\Simon\Desktop\samp server rpg\gamemodes\rpg-gm.pwn(111) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
|
You are trying to insert 2 variables into the same name. dini_SetInt works only with one argument.
Use different names for weapon id and ammo.
Re: Weapon saving -
sim_sima - 11.03.2011
Like
pawn Код:
new weapons[13], ammo[2];
for(new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], ammo[i][1]);
dini_IntSet(file, "Weapons", weapons[i][0], ammo[i][1]);
}
??
Re: Weapon saving -
Zh3r0 - 11.03.2011
Quote:
Originally Posted by sim_sima
Like
pawn Код:
new weapons[13], ammo[2]; for(new i = 0; i < 13; i++) { GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]); dini_IntSet(file, "Weapons", weapons[i][0], ammo[i][1]); }
??
|
No, like this:
pawn Код:
new weapons[13][2];
for(new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
dini_IntSet(file, "Weapon1", weapons[i][0]);
dini_IntSet(file, "Ammo1", weapons[i][1]);
}
Re: Weapon saving -
sim_sima - 11.03.2011
Ok, ill try it.
Re: Weapon saving -
sim_sima - 11.03.2011
Do i have to create a
"dini_IntSet(file, "Weapon1", weapons[i][0]);"
for every weapon slot?
Re: Weapon saving -
Zh3r0 - 11.03.2011
Quote:
Originally Posted by sim_sima
Do i have to create a
"dini_IntSet(file, "Weapon1", weapons[i][0]);"
for every weapon slot?
|
That, or use the loop!
pawn Код:
new weapons[13][2], Str[30];
for(new i = 0; i < 13; i++)
{
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
format( Str, 30, "Weapon%d", i );
dini_IntSet(file, Str, weapons[i][0]);
format( Str, 30, "Ammo%d", i );
dini_IntSet(file, "Ammo1", weapons[i][1]);
}
This will create from Weapon0 to Weapon12 also Ammo0 to Ammo12.