Saving jailtime to mysql
#1

Hello, I have /ajail command and I want that when you jail player the jailtime would be saving to mysql

That's the code

Код:
forward Unjail(playerid);
public Unjail(playerid)
{
SpawnPlayer(playerid);
SetPlayerInterior(playerid, 0);
PInfo[playerid][Jailed] = 0;
KillTimer(JailTimer[playerid]);
GameTextForPlayer(playerid, "~g~Unjailed", 5000, 6);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
}

CMD:ajail(playerid, params[])
{
new pID;
new Tplayer[MAX_PLAYER_NAME];
new name[24];
new time;
new reason[128];
GetPlayerName(pID,Tplayer,sizeof(Tplayer));
GetPlayerName(playerid,name,24);

if(sscanf(params, "uis[128]", pID, time,reason)) return SendClientMessage(playerid, COLOR_RED,"USAGE: /jail [playerid/name] [minutes] [reason]");
if(time <= 0) return SendClientMessage(playerid, COLOR_GREY, "Minutes can't be less than 0!");
if(pID == playerid) return SendClientMessage(playerid, COLOR_GREY, "You can't jail yourself!");
if(PInfo[playerid][Admin] == 0) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough privilegies to use this command!");
else
{
new str[128];
format(str, sizeof(str), "%s has been jailed by %s for %d minutes | Reason:!", name, Tplayer, time, reason);
SendClientMessageToAll(COLOR_LIGHTRED,str);
JailTimer[pID] = SetTimer("Unjail", time*60*1000, false);
SetPlayerPos(pID, 264.4176, 77.8930, 1001.0391);
SetPlayerInterior(pID, 6);
PInfo[pID][Jailed] = 1;
GameTextForPlayer(pID, "~p~JAILED", 10000, 6);
PlayerPlaySound(pID,1057,0.0,0.0,0.0);
}
return 1;
}
And that's the saving
[code=pawn]format(Query, sizeof(Query), "UPDATE Users SET Jailtime='%d' WHERE Username='%s'", WHAT TO WRITE HERE?,pName);[/code]
Reply
#2

Код:
format(Query, sizeof(Query), "UPDATE Users SET Jailtime='%d' WHERE Username='%s'", time, name);
I would've thought that was obvious.
Reply
#3

I want that the PInfo[playerid][JailTime] would be lower by 1 each second, can you help me?
Reply
#4

Quote:
Originally Posted by Yako
Посмотреть сообщение
I want that the PInfo[playerid][JailTime] would be lower by 1 each second, can you help me?
Sure. Just use a timer. Read this page on the wiki. Each 1,000 milliseconds, subtract 1 from the variable via either 'pInfo[playerid][JailTime]--' or pInfo[playerid][JailTime] = (pInfo[playerid][JailTime] - 1). Then every 30 seconds or some other reasonable interval, update the SQL database.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)