30.10.2011, 20:50
how to save on mysql, deaths ?? give me an example ?
#define TABLE_NAME "[table name here]"
new pDeath[MAX_PLAYERS];
public OnPlayerDeath(playerid, killerid, reason)
{
if(killerid != INVALID_PLAYER_ID)
{
pDeath[playerid]++;
}
}
public OnPlayerDisconnect(playerid)
{
// make sure you have already connected to the database
new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name));
mysql_query("UPDATE %s SET death = '%d' WHERE name = '%s'", TABLE_NAME, pDeath[playerid], name);
}
Somewhere at the top
pawn Код:
pawn Код:
|
new query[256];
format(query, sizeof (query), "UPDATE `users` SET `death` = %d WHERE `name` = '%s'", pDeath[playerid], name);
mysql_query(query);
new query[256];
mysql_format(-1, query, "UPDATE `users` SET `death` = %d WHERE `name` = '%s'", pDeath[playerid], name);
mysql_query(query);