Author Topic: How to save Health and Armour with dini ?  (Read 2298 times)

0 Members and 1 Guest are viewing this topic.

Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
How to save Health and Armour with dini ?
« 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]
« Last Edit: February 05, 2012, 05:29:03 pm by sseebbyy »

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.



Offline stormeus

  • VC:MP Developer
  • VC:MP Veteran
  • *
  • Posts: 1122
    • View Profile
Re: How to save Health and Armour with dini ?
« Reply #1 on: February 05, 2012, 06:49:07 pm »
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.
Do not PM me for support.




Offline sseebbyy

  • VC:MP Veteran
  • *****
  • Posts: 774
  • Immortal VC:MP Player
    • View Profile
    • Zombie Invasion => Server Forum [DEAD PROJECT]
Re: How to save Health and Armour with dini ?
« Reply #2 on: February 05, 2012, 08:03:06 pm »
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   :)

Code: [Select]
Health=83.000000
Armour=24.000000


Great !

And ... dini_SetFloat not work ..

Code: [Select]
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.

Quote
Painful/Noob scripters acts like: I Am The Best Scripter Because I Announce My Releases With Big Font Size Without Giving Too Much Info' In The Hope They All Will Download And Check It. I Ignore Bad Replies, Replies That I Could Learn From, And Replies With So Much Text.