Jump to content

Se insereaza id in loc de nume in baza de date la log


tyger

Recommended Posts

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
Link to comment
Share on other sites

  • 2 weeks later...

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;

                        

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.