Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Correct me if i'm wrong.

$
0
0
Hey all,
I created a ban system and wanna load the banned status on player connect
Code:

public OnPlayerConnect(playerid)
{
        new query[256],pname[24],dialog[256];
        GetPlayerName(playerid, pname, 24);
        format(query, sizeof(query), "SELECT * FROM bans WHERE username = '%s'",pname);
        mysql_query(query);
        mysql_store_result();
        new row[128];
        new field[5][32];
        mysql_fetch_row_format(row, "|");
        explode(row, field, "|");
        mysql_free_result();
        Banned[playerid] = strval(field[1]);
        if(Banned[playerid] == 1)
        {
                format(dialog, sizeof(dialog), "You are banned from this server\nUsername : %s\nReason : %s\nBanning Admin : %s",pname,field[2],field[3]);
                ShowPlayerDialog(playerid, DIALOG_BANNED, DIALOG_STYLE_MSGBOX, "Banned", dialog, "Ok", "");
                Kick(playerid);
        }
        return 1;
}

This is my code, if its wrong to save Banned to the variable correct me.
NP : i use Westie explode function :
Code:

explode(const sSource[], aExplode[][], const sDelimiter[] = " ", iVertices = sizeof aExplode, iLength = sizeof aExplode[]) // Created by Westie
{
        new
                iNode,
                iPointer,
                iPrevious = -1,
                iDelimiter = strlen(sDelimiter);

        while(iNode < iVertices)
        {
                iPointer = strfind(sSource, sDelimiter, false, iPointer);

                if(iPointer == -1)
                {
                        strmid(aExplode[iNode], sSource, iPrevious, strlen(sSource), iLength);
                        break;
                }
                else
                {
                        strmid(aExplode[iNode], sSource, iPrevious, iPointer, iLength);
                }

                iPrevious = (iPointer += iDelimiter);
                ++iNode;
        }
        return iPrevious;
}

Thanks in advance for helping me

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>