Vice City Multiplayer
VC:MP 0.3 => mIRC/pawn Scripting => Topic started by: sseebbyy on February 05, 2012, 05:26:40 pm
-
I want to save the player health and armour but i can't make this ...
I tried and i tried and i tried but nothing ...
My last attempt [not work] :
[pawn]public SaveInfo()
{
for(new i = 0; i <= MAX_PLAYERS; i++) {
if(IsPlayerConnected(i) && PlayerInfo[Spawned] == 1 && PlayerInfo[Logged] == 1) {
format(file, sizeof(file), USERS_FILE, gPlayers);
new Float:health,Float:armour,string[256],str[256];
GetPlayerHealth(i,health);
format(string,sizeof(string),"%s",health);
GetPlayerHealth(i,armour);
format(str,sizeof(str),"%s",armour);
dini_Set(file, "Health", string);
dini_Set(file, "Armour", str);
}
}
}[/pawn]
-
Trying to format a string using a float and %s will not work. %s only works with strings. The basic types you can use are:
%s - String
%c - Character
%i - Integer
%f - Float
So your code should look more like:
[pawn]
format(string,sizeof(string),"%f",health);
format(str,sizeof(str),"%f",armour);
[/pawn]
OR, you can use dini_SetFloat( file, "Health", health ); and such, which is simpler and spares the memory reserved from having to create a string.
-
Trying to format a string using a float and %s will not work. %s only works with strings. The basic types you can use are:
%s - String
%c - Character
%i - Integer
%f - Float
So your code should look more like:
[pawn]
format(string,sizeof(string),"%f",health);
format(str,sizeof(str),"%f",armour);
[/pawn]
OR, you can use dini_SetFloat( file, "Health", health ); and such, which is simpler and spares the memory reserved from having to create a string.
Work !
Thank You Stormeus :)
Health=83.000000
Armour=24.000000
Great !
And ... dini_SetFloat not work ..
D:\Jocuri\Grand Theft Auto Vice City\SERVER\~HIDE~\gamemodes\mode.pwn(739) : error 017: undefined symbol "dini_SetFloat"
D:\Jocuri\Grand Theft Auto Vice City\SERVER\~HIDE~\gamemodes\mode.pwn(740) : error 017: undefined symbol "dini_SetFloat"
Pawn compiler 3.0.3367 Copyright (c) 1997-2005, ITB CompuPhase
2 Errors.