INI_WriteString not writing first character.
#1

For some reason ini writestring is not writing the first character of a players name to their userfile. I'll show you all relevant code below.

Here's what it's writing:
Код:
pVehicleOwner = ason_Budley
Clearly it's suppose to have a "J" for Jason.

Relevant code:

pawn Код:
//part of the players enum
pVehicleOwner[32],


//saving user stock
INI_WriteString(file,"pVehicleOwner", pInfo[playerid][pVehicleOwner]);

//loading user
INI_String("pVehicleOwner",pInfo[playerid][pVehicleOwner], 32);

//the dialog where they purchase a car (saving it to their variable.)
pInfo[playerid][pVehicleOwner] = GetName(playerid);


//The getname stock.
stock GetName(playerid)
{
    new string[32];
    GetPlayerName(playerid, string,sizeof(string));
    return string;
}
Thanks for any assistance provided.
Reply
#2

There should be a problem on your stock. Try to debug it.
pawn Код:
stock GetName(playerid)
{
    new string[32];
    GetPlayerName(playerid, string,sizeof(string));
    print(string);
    return string;
}
Reply
#3

Stock works fine bud. Debug successful.
Reply
#4

Well first of all, [32] should be changed to [MAX_PLAYER_NAME] or [24] for starters. Other than that, I can't see anything wrong with the code you've given. Is there any other places that you use or change [pVehicleOwner]?
Reply
#5

pawn Код:
//the dialog where they purchase a car (saving it to their variable.)
pInfo[playerid][pVehicleOwner] = GetName(playerid);
try converting it to this--
pawn Код:
//the dialog where they purchase a car (saving it to their variable.)
format(pInfo[playerid][pVehicleOwner], 32,"%s", GetName(playerid));
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
As a general rule, when there's a bug you don't know the cause of, you can't just post little bits of your code. If you don't know where the bug is, then by definition you don't know the bug is in the code you posted.
Then how exactly would I debug it, without knowing the issue? I come here for assistance if I don't know where/why there's a bug just like any other person.

For the rest - I'll try your suggestions regarding max name and formatting it.

EDIT: formatting it writes this to their user file. (First letter should be "S").
Код:
eamore_Hoffman

EDIT2: Not sure if you need this, but I'm assigning the string variable to a player vehicle. Could this be causing the issue?

pawn Код:
pInfo[playerid][pVehicleOwner] = CreateVehicle(549, 371.3720,-93.7015,1.3727, 98.9953, 0, 0, -1);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)