MySQL R31 - Won't update -
WopsS - 06.09.2013
Hey, I have a problem. When I want to update money for a player it won't work... This is my code, i put
pawn Код:
Update(playerid, pMoneyx);
at
OnPlayerDisconnect but nothing.
pawn Код:
// This script is made by WopsS
forward Update(playerid, type);
#define pLevelx 1
#define pAdminx 2
#define pMoneyx 3
enum pInfo
{
pKey[128], pLevel, pAdmin, pEmail, pReg, pCash
};
new PlayerInfo[MAX_PLAYERS][pInfo];
public Update(playerid, type)
{
if(IsPlayerConnected(playerid))
{
new var[100];
new playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, sizeof(playerName));
{
switch(type)
{
case pLevelx:
{
format(var, 100,"UPDATE `players` SET `Level`='%d' WHERE `username`='%s'",PlayerInfo[playerid][pLevel],playerName);
mysql_tquery(1,var, "", "");
}
case pAdminx:
{
format(var, 100,"UPDATE `players` SET `AdminLevel`='%d' WHERE `username`='%s'",PlayerInfo[playerid][pAdmin],playerName);
mysql_tquery(1,var, "", "");
}
case pMoneyx:
{
format(var, 256,"UPDATE `players` SET `Money`='%d' WHERE `username`='%s'",PlayerInfo[playerid][pCash],playerName);
mysql_tquery(1,var, "", "");
}
}
}
}
}
Re: MySQL R31 - Won't update -
dusk - 06.09.2013
Could you enable debuging and show us the mysql log?
Re: MySQL R31 - Won't update -
WopsS - 06.09.2013
Yes, I have. But it is empty...
Re: MySQL R31 - Won't update -
Konstantinos - 06.09.2013
Fix few things:
pawn Код:
var[100]
// ----
format(var, 256
Adding greater size that it's been declared.
And change to:
pawn Код:
mysql_function_query(/* your connection id handle here */, var, false, "", "");
Re: MySQL R31 - Won't update -
WopsS - 06.09.2013
pawn Код:
forward Update(playerid, type);
#define pLevelx 1
#define pAdminx 2
#define pMoneyx 3
#define pLastLoginx 4
enum pInfo
{
pKey[128], pLevel, pAdmin, pEmail, pReg, pCash, pLastLogin[128]
};
new PlayerInfo[MAX_PLAYERS][pInfo];
public Update(playerid, type)
{
if(IsPlayerConnected(playerid))
{
new var[256];
new playerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerName, sizeof(playerName));
{
switch(type)
{
case pLevelx:
{
format(var, 256,"UPDATE `players` SET `Level`='%d' WHERE `username`='%s'",PlayerInfo[playerid][pLevel],playerName);
mysql_function_query(handle ,var, false, "", "");
}
case pAdminx:
{
format(var, 256,"UPDATE `players` SET `AdminLevel`='%d' WHERE `username`='%s'",PlayerInfo[playerid][pAdmin],playerName);
mysql_function_query(handle ,var, false, "", "");
}
case pMoneyx:
{
format(var, 256,"UPDATE `players` SET `Money`='%d' WHERE `username`='%s'",PlayerInfo[playerid][pCash],playerName);
mysql_function_query(handle ,var, false, "", "");
}
}
}
}
}
But nothing...
Re: MySQL R31 - Won't update -
Luis- - 06.09.2013
Why are you using a var size of 256?
Re: MySQL R31 - Won't update -
WopsS - 06.09.2013
For test. It was size of 100.
Re: MySQL R31 - Won't update -
WopsS - 06.09.2013
I make a command for level and not updates it. Someone?