Set String From Database. - Not loading
#1

when i set it from database: saids

This work but if i close the server then start it back up.
Код:
[17:15:02] [plugins/mysql] cache_get_value_name_int: value 'lol' is not a number
OnPlayerDisconnect:
Код:
mysql_format(mysql, query, sizeof(query), "UPDATE `accounts` SET `SCORE`= %i , `Admin` = '%i' , `personalmsg` = '%e' WHERE `ID` = '%d'", GetPlayerScore(playerid), PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][personalmsg], PlayerInfo[playerid][ID]);
Код:
UPDATE `accounts` SET `personalmsg` = 'lol' WHERE `accounts`.`ID` = 3;
then when start the server. then login to the server and to my account
error pop up
Код:
[17:15:02] [plugins/mysql] cache_get_value_name_int: value 'lol' is not a number
RegisterDialog:
Код:
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `personalmsg`, `Admin`, `Money`) VALUES ('%e', '%e', '%e', 0, 0,'%e')", Name[playerid], PlayerInfo[playerid][Password], IP[playerid], PlayerInfo[playerid][personalmsg]);
Код:
forward OnAccountLoad(playerid);
public OnAccountLoad(playerid)
{
    cache_get_value_name_int(0, "Admin", PlayerInfo[playerid][pAdmin]);
    cache_get_value_name_int(0, "Score", PlayerInfo[playerid][Score]);
    cache_get_value_name_int(0, "personalmsg", PlayerInfo[playerid][personalmsg]);
    
    GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
    SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
    

    return true;
}
Reply
#2

Because "lol" isn't an integer and you're trying to retrieve "personalmsg" as an integer using cache_get_value_name_int. The log clearly says it! You've to retrieve it as a string using cache_get_value_name.
Reply
#3

It won't load from database or command.
my error logs are clear.

Код:
    cache_get_value_name(0, "personalmsg", PlayerInfo[playerid][personalmsg]);
Reply
#4

You need to put string length at 4th parameter, as 'personalmsg' is an enum.
Код:
cache_get_value_name(0, "personalmsg", PlayerInfo[playerid][personalmsg], length of personalmsg here);
Reply
#5

Quote:
Originally Posted by X337
Посмотреть сообщение
You need to put string length at 4th parameter, as 'personalmsg' is an enum.
Код:
cache_get_value_name(0, "personalmsg", PlayerInfo[playerid][personalmsg], length of personalmsg here);
Thank you so much X337 it worked.
Worked from the database. Do i need personalmsg[129] in my enum?

Код:
enum pInfo
{
    pAdmin,
    pWork,
    StartingPoint,
    EndingPoint,
    pConvoy,
    MissionID,
    ID,
    Password[129],
    Score,
    Money,
    personalmsg[129],
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Reply
#6

Yes It'd be handy.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)