Saving admin jail to mysql - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Saving admin jail to mysql (
/showthread.php?tid=611111)
Saving admin jail to mysql -
Zeus666 - 02.07.2016
I've found an tutorial
Код:
new
weaponid,
ammo;
for(new i; i < 13; i++) // looping through all weapon slots (0 - 12)
{
GetPlayerWeaponData(playerid, i, weaponid, ammo); // get weaponid and ammo
if(!weaponid) continue; // don't insert if there's no weapon in this slot
mysql_format(userDB, mysqlquery, sizeof(mysqlquery), "INSERT INTO player_weapons VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE ammo = %d;", PlayerInfo[playerid][pSQLID], weaponid, ammo, ammo);
mysql_pquery(userDB, mysqlquery); // parallel queries
}
SELECT weaponid, ammo FROM player_weapons WHERE userid = %d;
public OnLoadPlayerWeapons(playerid)
{
new
weaponid,
ammo;
for(new i, j = cache_get_row_count(userDB); i < j; i++) // loop through all the rows that were found
{
weaponid = cache_get_row_int(i, 0, userDB);
ammo = cache_get_row_int(i, 1, userDB);
if(!(0 <= weaponid <= 46)) // check if weapon is valid (should be)
{
printf("[info] Warning: OnLoadPlayerWeapons - Unknown weaponid '%d'. Skipping.", weaponid);
continue;
}
GivePlayerWeapon(playerid, weaponid, ammo);
}
return;
}
But this is for weapon. I want to make for admin jail
Код:
forward AjailCount(playerid);
public AjailCount(playerid)
{
if(pInfo[playerid][pJailTime] != 0)
{
pInfo[playerid][pJailTime]--;
if(pInfo[playerid][pJailTime] == 0)
{
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
}
}
return 1;
}
CMD:ajail(playerid, params[])
{
new targetid, time, reason[64];
new string[128], adminname[64], targetname[64];
if(pInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid, COLOR_RED, "ERROR: You are not Admin");
if(sscanf(params, "uds[64]", targetid, time, reason)) return SendClientMessage(playerid, -1, "USAGE: /ajail <playerid> <time> <reason>");
if(time == 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: Minimum 1 minute !");
GetPlayerName(targetid, targetname, MAX_PLAYER_NAME);
GetPlayerName(playerid, adminname, MAX_PLAYER_NAME);
SetPlayerPos(targetid, 346.870025, 309.259033, 999.155700);
SetPlayerVirtualWorld(targetid, 2);
SetPlayerInterior(targetid,6);
pInfo[targetid][pJailTime] = time;
format(string, sizeof(string), "Administrator %s ajailed %s for %d minutes. Reason: %s", adminname, targetname, time, reason);
SendClientMessageToAll(COLOR_RED, string);
playertimer[targetid] = SetTimerEx("AjailCount", 60000, 1, "i", playerid);
return 1;
}
CMD:unjail(playerid, params[])
{
new targetid;
if(pInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid, COLOR_RED, "ERROR: Nu ai nivelul de administrator necesar!");
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "USAGE: /unajail <playerid>");
if(pInfo[targetid][pJailTime] == 0) return SendClientMessage(playerid, COLOR_RED, "ERROR: Jucatorul nu este in jail momentan!");
SetPlayerPos(playerid, 1529.6,-1691.2,13.3);
SetPlayerInterior(playerid, 0);
SetPlayerVirtualWorld(playerid, 0);
pInfo[playerid][pJailTime] = 0;
return 1;
}
I want to set AjailCount to be saved when player quits and when he joins back, AjailCount shall work from where it stoped.
To set how many times a player got ajailed (with minutes and reason too)
How should I edit the tutorial to make good for mine?
Re: Saving admin jail to mysql -
Zeus666 - 03.07.2016
bump