25.06.2017, 15:46
Hey all,
I created a ban system and wanna load the banned status on player connect
This is my code, if its wrong to save Banned to the variable correct me.
NP : i use Westie explode function :
Thanks in advance for helping me
I created a ban system and wanna load the banned status on player connect
Код:
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; }
NP : i use Westie explode function :
Код:
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; }