[Ajuda] comando /jail com sistema diferenciado
#1

Estou desenvolvendo um GameMode DM e desenvolver um GM й muuito mais fбcil do que desenvolver um sistema Admin [FS], jб que o GM tem mais foco nos comandos/sistemas mais simples...

Este sistema de prisгo й do FS do Gammix, eu apenas alterei algumas coisas:
PHP код:
CMD:jail(playeridparams[])
{
    
//check if the player is a admin
    //LevelCheck(playerid, 2);
    
new targettimereason[128];
    if(
sscanf(params"uI(60)S(No reason specified)[128]"targettimereason)) return SendClientMessage(playeridCOLOR_THISTLE"USAGE: /jail [player] [*seconds] [*reason]");
    if(! 
IsPlayerConnected(target)) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: The specified player is not conected.");
    if(
GetPlayerGAdminLevel(playerid) < GetPlayerGAdminLevel(target)) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: You cannot use this command on higher level admin.");
    if(
time 5*60 || time 10) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: The jail time must be b/w 10 - 360(5 minutes) seconds.");
    
//if(target == playerid) return SendClientMessage(playerid, COLOR_FIREBRICK, "ERROR: You cannot jail yourself.");
    
if(gUser[target][u_jailed] == 1) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: Player is already in jail.");
    
gUser[target][u_jailed] = 1;
    
gUser[target][u_jailtime] = time;
    
    
JailPlayer(target);
    
PlayerPlaySound(target10570.00.00.0);
    
PlayerPlaySound(playerid10570.00.00.0);
    new 
string[144];
    
format(stringsizeof(string), "* %s[%i] has been jailed by admin %s[%i] for %i seconds [Reason: %s]"ReturnPlayerName(target), targetReturnPlayerName(playerid), playeridtimereason);
    
SendClientMessageToAll(COLOR_DODGER_BLUEstring);
    
format(stringsizeof(string), "~b~~h~~h~~h~Jailed for %i secs"time);
    
GameTextForPlayer(targetstring50003);
    
    new 
key DB::RetrieveKey(gGlobal[s_usertable], "username"ReturnPlayerName(playerid));
    
DB::SetIntEntry(gGlobal[s_usertable], key"jailed"gUser[target][u_jailed]);
    
DB::SetIntEntry(gGlobal[s_usertable], key"jailtime"gUser[target][u_jailtime]);
    
    
key DB::RetrieveKey(gGlobal[s_statscount], "username"ReturnPlayerName(playerid));
    
DB::SetIntEntry(gGlobal[s_statscount], key"jailcount+"gUser[target][u_jailcount]);
    
SaveStatsCount(playerid);
    return 
1;

Eu havia feito um sistema neste mesmo FS. Sistema de contagem de kicks! realmente bom e ъtil e nгo um sistema tosco e ocupador de linhas....
Minha ideia foi fazer a contagem de quantas vezes o player foi preso, tipo como isso:

PHP код:
CMD:jail(playeridparams[])
{
    
//check if the player is a admin
    //LevelCheck(playerid, 2);
    
new targettimereason[128];
    if(
sscanf(params"uI(60)S(No reason specified)[128]"targettimereason)) return SendClientMessage(playeridCOLOR_THISTLE"USAGE: /jail [player] [*seconds] [*reason]");
    if(! 
IsPlayerConnected(target)) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: The specified player is not conected.");
    if(
GetPlayerGAdminLevel(playerid) < GetPlayerGAdminLevel(target)) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: You cannot use this command on higher level admin.");
    if(
time 5*60 || time 10) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: The jail time must be b/w 10 - 360(5 minutes) seconds.");
    
//if(target == playerid) return SendClientMessage(playerid, COLOR_FIREBRICK, "ERROR: You cannot jail yourself.");
    
if(gUser[target][u_jailed] == 1) return SendClientMessage(playeridCOLOR_FIREBRICK"ERROR: Player is already in jail.");
    
gUser[target][u_jailed] = 1;
        
gUser[target][u_jailed]++; // FAZ  A CONTAGEM
    
gUser[target][u_jailtime] = time;
    
    
JailPlayer(target);
    
PlayerPlaySound(target10570.00.00.0);
    
PlayerPlaySound(playerid10570.00.00.0);
    new 
string[144];
    
format(stringsizeof(string), "* %s[%i] has been jailed by admin %s[%i] for %i seconds [Reason: %s]"ReturnPlayerName(target), targetReturnPlayerName(playerid), playeridtimereason);
    
SendClientMessageToAll(COLOR_DODGER_BLUEstring);
    
format(stringsizeof(string), "~b~~h~~h~~h~Jailed for %i secs"time);
    
GameTextForPlayer(targetstring50003);
    
    new 
key DB::RetrieveKey(gGlobal[s_usertable], "username"ReturnPlayerName(playerid));
    
DB::SetIntEntry(gGlobal[s_usertable], key"jailed"gUser[target][u_jailed]);
        
DB::SetIntEntry(gGlobal[s_usertable], key"jailed"gUser[target][u_jailedcount]);
    
DB::SetIntEntry(gGlobal[s_usertable], key"jailtime"gUser[target][u_jailtime]);
    return 
1;

FAZ A CONTAGEM
Quote:

gUser[target][u_jailed]++;

SETA A COLUNA 'u_jailedcount' DA TABLE DO PLAYER ESPECIFICADO
Quote:

DB::SetIntEntry(gGlobal[s_usertable], key, "jailed", gUser[target][u_jailedcount]);

Reply
#2

Qual o problema?
Reply
#3

Nгo й problema, olha o que eu fiz:

Quote:

DB::SetIntEntry(gGlobal[s_statscount], key, "jailcount+", gUser[target][u_jailcount]+=gUser[target][u_jailed]);

Ele soma o 'gUser[target][u_jailed]' conforme for setado como 1, ai beleza, mas agora eu quero fazer para salvar os segundos e se eu colocar desta forma os segundos aparecem errados, e outra, eu quero q os segundos aumentem de 1 em 1 segundo (callback OnPlayerUpdate):

Quote:

if(gUser[playerid][u_jailed] == 1)
{
if(gUser[playerid][u_jailtime] >= 1)
{
gUser[playerid][u_jailtime] -= 1;
gUser[playerid][u_jailed] = 1;
new key = DB::RetrieveKey(gGlobal[s_usertable], "username", ReturnPlayerName(playerid));
DB::SetIntEntry(gGlobal[s_usertable], key, "jailed", gUser[target][u_jailed]);
DB::SetIntEntry(gGlobal[s_usertable], key, "jailtime", gUser[target][u_jailtime]);
}
else if(gUser[playerid][u_jailtime] <= 0)
{
gUser[playerid][u_jailtime] = 0;
gUser[playerid][u_jailed] = 0;
format(string, sizeof(string), "* %s[%d] has been unjailed after completing his/her time.", ReturnPlayerName(playerid), playerid);
SendClientMessageToAll(COLOR_STEEL_BLUE, string);
SpawnPlayer(playerid);
new key = DB::RetrieveKey(gGlobal[s_usertable], "username", ReturnPlayerName(playerid));
DB::SetIntEntry(gGlobal[s_usertable], key, "jailed", gUser[target][u_jailed]);
DB::SetIntEntry(gGlobal[s_usertable], key, "jailtime", gUser[target][u_jailtime]);
}
}

Este code estб em OnPlayerUpdate e funfa de boa (diminui [-1] segundo preso). Quero que aumente esse +1 segundo em outra coluna, fazendo com que mostre o total de segundos preso!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)