Y_INI String
#1

I'm having an issue with a Y_INI string. I've basically put it so it saves an input from a dialog as a string and on another dialog box it reads that value. On the saving part it works perfectly fine but on the reading part it has an issue as it doesnt even't write the name. ( It shows nothing in return )

Here's my loading method

pawn Код:
// From the enum array
CharacterName[128],

// From LoadUser Method
INI_Int("CharacterName", PlayerData[playerid][CharacterName]);
Saving Method ( Saves perfectly the input name into the .ini )

pawn Код:
format(PlayerData[playerid][CharacterName], 128, "%s",inputtext);
new INI:File = INI_Open(UserPath(playerid));
INI_WriteString(File, "CharacterName", PlayerData[playerid][CharacterName]);
INI_Close(File);
And here's the part which doesn't work ( It's supposed to print Your Name: Name_Surname ( Which it should read from the .ini but instead it prints just Your Name: ) )

pawn Код:
new szString[128];
format(szString, sizeof(szString), "Your Character: %s", PlayerData[playerid][CharacterName]);
ShowPlayerDialog(playerid, DIALOG_LOGINCHARACTER, DIALOG_STYLE_INPUT, "Omega Roleplay", szString, "Login", "")
Reply
#2

what if you make a stock called getplayername

it would be easy and better

use wikis -_-
Reply
#3

Quote:
Originally Posted by verlaj
Посмотреть сообщение
what if you make a stock called getplayername

it would be easy and better

use wikis -_-
What about next time you reply, read properly my question?

I don't wanna get the player's current name I want to get a string variable from the player's character folder. ( From his .ini file).

and just to make it clear Player's Nickname != Character name
Reply
#4

Help anyone?
Reply
#5

Use Dini include. It is so easy to use.
Reply
#6

Quote:
Originally Posted by ProjectMan
Посмотреть сообщение
Use Dini include. It is so easy to use.
Well I already added the Y_INI method so I would need to remove & readd again the files on Dini.
Reply
#7

PHP код:
INI_Int("CharacterName"PlayerData[playerid][CharacterName]); 
Should be

PHP код:
 INI_String("CharacterName"PlayerData[playerid][CharacterName], sizeof(PlayerData[playerid][CharacterName])); 
Or, if you want it shorter:
PHP код:
 INI_String("CharacterName"PlayerData[playerid][CharacterName], 128); 
No difference between the two, except that at the first one we use a function called sizeof which gets the size of the variable.
I'm guessing the 2nd will be faster though. Since the sizeof function goes through some stuff to get the size whereas the 2nd one directly has the string size.

You want to load a string not an integer, so you use INI_String not INI_Int.

Also, don't ever use dini. It's very slow.
Reply
#8

I've tried that aswell but I get those errors when I do so.

pawn Код:
C:\Users\Administrator\Desktop\sampl0l0l0p\gamemodes\OmegaRoleplay.pwn(225) : error 001: expected token: "]", but found "-identifier-"
C:\Users\Administrator\Desktop\sampl0l0l0p\gamemodes\OmegaRoleplay.pwn(225) : warning 215: expression has no effect
C:\Users\Administrator\Desktop\sampl0l0l0p\gamemodes\OmegaRoleplay.pwn(225) : error 001: expected token: ";", but found "]"
C:\Users\Administrator\Desktop\sampl0l0l0p\gamemodes\OmegaRoleplay.pwn(225) : error 029: invalid expression, assumed zero
C:\Users\Administrator\Desktop\sampl0l0l0p\gamemodes\OmegaRoleplay.pwn(225) : fatal error 107: too many error messages on one line
Reply
#9

Your code?
Reply
#10

Quote:
Originally Posted by gtakillerIV
Посмотреть сообщение
Your code?
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password", PlayerData[playerid][Password]);
    INI_Int("Health", PlayerData[playerid][Health]);
    INI_Int("Skin", PlayerData[playerid][Skin]);
    INI_Int("Armour", PlayerData[playerid][Armour]);
    INI_Int("TutorialCompleted", PlayerData[playerid][TutorialCompleted]);
    INI_Int("InTutorial", PlayerData[playerid][InTutorial]);
    INI_Int("PosX", PlayerData[playerid][PosX]);
    INI_Int("PosY", PlayerData[playerid][PosY]);
    INI_Int("PosZ", PlayerData[playerid][PosZ]);
    //INI_Int("Registered", PlayerData[playerid][Registered]);
    INI_Int("IsLogged", PlayerData[playerid][IsLogged]);
    INI_Int("AdministratorLevel", PlayerData[playerid][AdministratorLevel]);
    INI_Int("ModeratorLevel", PlayerData[playerid][ModeratorLevel]);
    INI_Int("Helper", PlayerData[playerid][Helper]);
    INI_Int("DonatorLevel", PlayerData[playerid][DonatorLevel]);
    INI_Int("WeaponA", PlayerData[playerid][WeaponA]);
    INI_Int("WeaponB", PlayerData[playerid][WeaponB]);
    INI_String("CharacterName", PlayerData[playerid][CharacterName], sizeof(PlayerData[playerid][CharacterName]));
    INI_Int("Cash", PlayerData[playerid][Cash]);
    INI_Int("Gender", PlayerData[playerid][Gender]);
    INI_Int("Age", PlayerData[playerid][Age]);
    INI_Int("Username", PlayerData[playerid][Username]);

    return 1;
}
That with the string you told me

EDIT: This is the loadingmethod already posted above some others methods that have to do with charactername
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)