13.10.2010, 06:55
Example:
pawn Code:
public OnPlayerConnect(playerid)
{
new
value,
name[24],
query[79],
field[12];
GetPlayerName(playerid, name, sizeof(name)); // we need the name of the player to make the query
format(query, sizeof(query), "SELECT keycar FROM players WHERE Nickname = '%s' LIMIT 1", name); // we format "query"
// it means it will look for the content of "keycar" in the table "players" where the nickname is the name of the player,
// LIMIT 1 means it will only take the first value
mysql_query(query); // we make the query with "query" ("SELECT keycar FROM blablabla")
mysql_store_result(); // we store the result of the query
if(mysql_num_rows() > 0) // if theres any value then:
{
mysql_fetch_row_format(field); // fetch the value to the string "field"
value = strval(field); // convert the string to an integer
}
mysql_free_result(); // free the mysql memory
return 1;
}