Jump to content

Recommended Posts

Posted (edited)

Salutare 
 
Am o functie care imi updateaza in baza de date banurile, problema este ca in loc sa imi insereze Numele adminul care a dat ban si numele banatului imi insereaza ID-urile conturilor lor.
 
Ma puteti ajuta sa rezolv? Las functia mai jos:

forward Banlog(ip[],psql,asql,reason[],day);



public Banlog(ip[],psql,asql,reason[],day)
{
    new query[500];
    new y,m,d,h,mi,s;
        getdate(y,m,d);
        gettime(h,mi,s);
    format(query,sizeof(query),"INSERT INTO banlog (`ip`,`player`,`admin`,`reason`,`day`,`time`) VALUES ('%s','%d','%d','%s','%d','%02d/%02d/%d %02d:%02d:%02d')",ip,psql,asql,reason,day,d,m,y,h,mi,s);
    mysql_query(SQL,query);
    return 1;
}


CMD:banex(playerid, params[])
{
    new name[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pAdmin] >= 1)
    {
        new giveplayerid,days,reason[128],string[128],giveplayer[25];
        if(sscanf(params, "uds[128]", giveplayerid,days,reason)) return SCM(playerid,COLOR_WHITE,"Tasteaza: /banex <Name/Playerid> <day> <Reason>");
        if(IsPlayerConnected(giveplayerid))
        {
            if(days <= 0 || days > 1000) return SendClientMessage(playerid, COLOR_WHITE, "Invalid Day! (1-1000)");
            GetPlayerName(playerid, name, sizeof name);
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            new year,month,day;
            getdate(year, month, day);
            day += days;
            if (IsMonth31(month))
            {
                if (day > 31)
                {
                    month += 1;
                    if (month > 12)
                    {
                        year += 1;
                        while(day > 31) day -= 31;
                    }
                    else while(day > 31) day -= 31;
                }
            }
            else if (!IsMonth31(month))
            {
                if (day > 30)
                {
                    month += 1;
                    if (month > 12)
                    {
                        year += 1;
                        while(day > 30) day -= 30;
                    }
                    else while(day > 30) day -= 30;
                }
            }
            else if (!IsMonth31(month) && IsMonth29(year) && month == 2)
            {
                if (day > 29)
                {
                    month += 1;
                    if (month > 12)
                    {
                        year += 1;
                        while(day > 29) day -= 29;
                    }
                    else while(day > 29) day -= 29;
                }
            }
            else if (!IsMonth31(month) && !IsMonth29(year) && month == 2)
            {
                if (day > 28)
                {
                    month += 1;
                    if (month > 12)
                    {
                        year += 1;
                        while(day > 28) day -= 28;
                    }
                    else while(day > 28) day -= 28;
                }
            }
            PlayerInfo[giveplayerid][pBTemp] = 1;
            PlayerInfo[giveplayerid][pBYear] = year;
            PlayerInfo[giveplayerid][pBMonth] = month;
            PlayerInfo[giveplayerid][pBDay] = day;
            strmid(PlayerInfo[giveplayerid][pBBy], name, 0, strlen(name), 255);
            strmid(PlayerInfo[giveplayerid][pBReason], reason, 0, strlen(reason), 255);
            Update(giveplayerid,pBTempx);
            Update(giveplayerid,pBYearx);
            Update(giveplayerid,pBMonthx);
            Update(giveplayerid,pBDayx);
            Update(giveplayerid,pBByx);
            Update(giveplayerid,pBReasonx);
            if(days == 1)
            {
                format(string,128,"AdmCmd: %s a fost banat de %s pentru %d zile, motiv: %s",giveplayer,name,days,reason);
                SendClientMessageToAll(0xf03337FF,string);
            }
            else if(days > 1)
            {
                format(string,128,"AdmCmd: %s a fost banat de %s pentru %d zile, motiv: %s",giveplayer,name,days,reason);
                SendClientMessageToAll(0xf03337FF,string);
            }
            new ip[25];
            GetPlayerIp(giveplayerid, ip, sizeof(ip));
            Banlog(ip,PlayerInfo[giveplayerid][pSQLID],PlayerInfo[playerid][pSQLID],reason,days);
            KickEx(giveplayerid);
        }
        else return SendClientMessage(playerid, COLOR_WHITE, "Jucatorul nu este conectat.");
    }
    else return SendClientMessage(playerid,COLOR_WHITE,AdminOnly);
    return true;
}

 

 

1. Cred ca e de la public Banlog deoarece psql si asql nu sunt definite ca sa imi updateze numele.

2. pSQLID imi defineste id-ul contului in baza de date. Pot sa creez si o functie la fel pt tabelul name daca este necesar.

 

Va rog sa ma ajutati sa rezolv.

 

 

Edited by tyger
  • 2 weeks later...
Posted

public Banlog(ip[],psql,asql,reason[],day)
{
   new name[MAX_PLAYER_NAME];
   foreach(Player, playerid)
   {
        GetPlayerName(playerid, name, sizeof(name));
   }
   new query[500];
   new y,m,d,h,mi,s;
   getdate(y,m,d);
   gettime(h,mi,s);
   format(query,sizeof(query),"INSERT INTO banlog (`ip`,`player`,`admin`,`reason`,`day`,`time`) VALUES ('%s','%d','%d','%s','%d','%02d/%02d/%d %02d:%02d:%02d')",ip,name,asql,reason,day,d,m,y,h,mi,s);
   mysql_query(SQL,query);
    return 1;

                        

 

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.