public GetPlayerInfo(playerid) {
new rows, fields, temp[70];
cache_get_data(rows, fields);
if (rows) {
cache_get_row(0, 0, temp); // Password
pInfo[playerid][pPass] = strval(temp);
cache_get_row(0, 1, temp); // Male
pInfo[playerid][pMale] = strval(temp);
cache_get_row(0, 2, temp); // Origin
format(pInfo[playerid][pOrigin], 30, "%s", temp);
cache_get_row(0, 3, temp); // Skin
pInfo[playerid][pSkin] = strval(temp);
cache_get_row(0, 4, temp); // Money
pInfo[playerid][pMoney] = strval(temp);
cache_get_row(0, 5, temp); // Bank Money
pInfo[playerid][pBankMoney] = strval(temp);
cache_get_row(0, 6, temp); // Banned
pInfo[playerid][pBanned] = strval(temp);
if (pInfo[playerid][pBanned] == 1) {
SCM(playerid, COLOR_ORANGE, "You are banned from this server!");
Kick(playerid);
}
}
return 1;
}
cache_get_field_content(0, "fieldname1", string1);
cache_get_field_content(0, "fieldname2", string2);
cache_get_field_content(0, "fieldname3", string3);
if (pInfo[playerid][pBanned] == 1) {
SCM(playerid, COLOR_ORANGE, "You are banned from this server!");
Kick(playerid);
}
format(szQuery, sizeof(szQuery), "SELECT `password`,`male`,`age`,`origin`,`skin`,`money`,`bankmoney`,`banned` FROM `users` WHERE `username` = '%s'", GN(playerid));
mysql_function_query(dbHandle, szQuery, true, "GetPlayerInfo", "d", playerid);
I suggest you to take a look at this tutorial:
https://sampforum.blast.hk/showthread.php?tid=337810 Good luck! |
That's how everyone is here, saying "could you please give me the code so I can learn."
I agree on that you can learn from what you read. But first try it yourself, and show us the code YOU did. You can do it. ![]() |
public GetPlayerInfo(playerid)
{
new rows, fields, temp[70];
cache_get_data(rows, fields);
if (rows) {
// you can just store origin into the var straight away without needing to format
cache_get_field_content(0, "Origin", pInfo[playerid][pOrigin]);
cache_get_field_content(0, "Password", temp); pInfo[playerid][pPass] = strval(temp);
cache_get_field_content(0, "Male", temp); pInfo[playerid][pMale] = strval(temp);
cache_get_field_content(0, "Skin", temp); pInfo[playerid][pSkin] = strval(temp);
cache_get_field_content(0, "Money", temp); pInfo[playerid][pMoney] = strval(temp);
cache_get_field_content(0, "BankMoney", temp); pInfo[playerid][pBankMoney] = strval(temp);
cache_get_field_content(0, "Banned", temp); pInfo[playerid][pBanned] = strval(temp);
if (pInfo[playerid][pBanned] == 1) {
SCM(playerid, COLOR_ORANGE, "You are banned from this server!");
Kick(playerid);
}
}
return 1;
}