![]() |
|
[Pawn] MySQL Weapon save custom - Printable Version +- open.mp forum (https://forum.open.mp) +-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) +--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) +--- Thread: [Pawn] MySQL Weapon save custom (/showthread.php?tid=811) |
MySQL Weapon save custom - Zow - 2019-09-30 They saved every weapon from the server after disconnected But I wants them to custom save exam: /getgun from the gang = not save /weapon = save sorry for my bad explain I don't know how to explain to be clear PHP Code: public OnPlayerDisconnect(playerid, reason)
{
for (new i = 0; i <= 12; i++)
{
GetPlayerWeaponData(playerid, i, weapons1[i][0], weapons1[i][1]);
if(!weapons1[i][0]) continue; // don't insert if there's no weapon in this slot
mysql_format(dbCon, query, sizeof(query), "INSERT INTO `WeaponData` (ID, WeaponID, Ammo) VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE `Ammo` = `Ammo` + %d", PlayerInfo[playerid][pSQLID], weapons1[i][0], weapons1[i][1], weapons1[i][1]);
mysql_query(dbCon, query);
printf("weapon: %d, ammo: %d", weapons1[i][0], weapons1[i][1]);
}
return 1;
}
PHP Code: if(strcmp(cmd, "/weapon", true) == 0)
{
GivePlayerWeapon(playerid, 24, 500);
GivePlayerWeapon(playerid, 30, 500);
GivePlayerWeapon(playerid, 8, 1);
}
PHP Code: if(strcmp(cmd, "/getgun", true) == 0)
{
GivePlayerWeapon(playerid, 24, 500);
GivePlayerWeapon(playerid, 30, 500);
GivePlayerWeapon(playerid, 8, 1);
}
RE: MySQL Weapon save custom - Tama - 2019-10-01 Make a detection variable and use it like this: PHP Code: new bool:gTemporaryGuns[MAX_PLAYERS]; //create a boolean (true/false)
public OnPlayerCommandText(playerid, cmdtext[])
{
? ? ? if (!strcmp(cmdtext, "/weapons", true))
? ? ? {
? ? ? ? ? ? ?//your code here.
? ? ? ? ? ? ?gTemporaryGuns[playerid] = false;
? ? ? }
? ? ? if(!strcmp(cmdtext, "/getgun", true))
? ? ? {
? ? ? ? ? ? ?//your code here.
? ? ? ? ? ? ?gTemporaryGuns[playerid] = true;
? ? ? }??
}
public OnPlayerDisconnect(playerid, reason)
{
? ? ? ??if (!gTemporaryGuns[playerid])?
? ? ? ?{
? ? ? ? ? ? ? ?for (new i = 0; i <= 12; i)
? ? ? ? ? ? ??{
? ? ? ? ? ? ? ? ? ? ? GetPlayerWeaponData(playerid, i, weapons1[i][0], weapons1[i][1]);
? ? ? ? ? ? ? ? ? ? ??if(!weapons1[i][0])?
? ? ? ? ? ? ? ? ? ? ? ? ? ??continue; // don't insert if there's no weapon in this slot
? ? ? ? ? ? ? ? ? ? ??mysql_format(dbCon, query, sizeof(query), "INSERT INTO `WeaponData` (ID, WeaponID, Ammo) VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE `Ammo` = `Ammo` %d", PlayerInfo[playerid][pSQLID], weapons1[i][0], weapons1[i][1], weapons1[i][1]);
? ? ? ? ? ? ? ? ? ? ??mysql_query(dbCon, query);
? ? ? ? ? ? ? ? ? ? ??printf("weapon: %d, ammo: %d", weapons1[i][0], weapons1[i][1]);
? ? ? ? ? ? }
? ? ?}
}
So, with this, you can save only gun from /weapon. I just give you an example tho, don't blame me if this not work :3 |