Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <a_mysql>
- native gpci (playerid, serial [], len);
- new gpci_joueur[128], MySQL, requete[1024];
- public OnFilterScriptInit()
- {
- MySQL = mysql_connect("localhost", "root", "votre_base_de_donnees", "");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- gpci(playerid, gpci_joueur, sizeof(gpci_joueur));
- format(requete, 1024, "SELECT * FROM Banlist WHERE gpci='%s'", gpci_joueur);
- mysql_tquery(MySQL, requete);
- mysql_store_result();
- if(mysql_num_rows() > 0)
- {
- SendClientMessage(playerid, -1, "{FF0000}[Erreur]{FFFFFF} Vous êtes banni.");
- Kick(playerid);
- }
- else return SendClientMessage(playerid, -1, " {013FD1}[Acceuil]{FFFFFF} Bienvenue sur le serveur !");
- return 1;
- }
- BanGPCI(playerid, adminname[], raison[])
- {
- new heures, minutes, secondes, jour, mois, annee;
- gettime(heures, minutes, secondes);
- getdate(annee, mois, jour);
- gpci(playerid, gpci_joueur, sizeof(gpci_joueur));
- format(requete, 1024, "INSERT INTO Banlist VALUES (NULL, '%s', '%s', '%d-%d-%d %d:%d:%d', '%s');", gpci_joueur, adminname, annee, mois, jour, heures, minutes, secondes, raison);
- mysql_tquery(MySQL, requete);
- Kick(playerid);
- }
- strtok(const string[], &index, const seperator[] = " ")
- {
- const size = 30;
- new idx = strfind(string, seperator, false, index), result[size];
- if(idx == -1)
- {
- if((idx = strlen(string)) > index)
- strmid(result, string, index, idx, size),index = idx;
- }
- else if(idx > (index + size - 1))
- strmid(result, string, index, (idx = index + size - 1), size), index = idx;
- else strmid(result, string, index, idx, size), index = idx + 1;
- return result;
- }
- stock isNumeric(const string[])
- {
- new length=strlen(string);
- if (length==0) return false;
- for (new i = 0; i < length; i++)
- {
- if (
- (string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+') // Not a number,'+' or '-'
- || (string[i]=='-' && i!=0) // A '-' but not at first.
- || (string[i]=='+' && i!=0) // A '+' but not at first.
- ) return false;
- }
- if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
- return true;
- }
- #define RETURN_USER_FAILURE -1
- #define RETURN_USER_MULTIPLE -2
- stock ReturnUser(text[])
- {
- new pos = 0;
- new userid = RETURN_USER_FAILURE;
- while(text[pos] < 0x21) { // Strip out leading spaces
- if(text[pos] == 0) return RETURN_USER_FAILURE; // No passed text
- pos++;
- }
- if(isNumeric(text[pos])) { // Check whole passed string
- userid = strval(text[pos]);
- if(userid >=0 && userid < MAX_PLAYERS)
- {
- if(IsPlayerConnected(userid)) return userid;
- return RETURN_USER_FAILURE;
- }
- }
- // They entered [part of] a name or the id search failed (check names just incase)
- new len = strlen(text[pos]);
- new count = 0;
- new name[MAX_PLAYER_NAME+1];
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- GetPlayerName(i, name, sizeof(name));
- if(strcmp(name, text[pos], true, len) == 0) // Check segment of name
- {
- if(len == strlen(name)) { // Exact match
- return i;
- }
- else { // Partial match
- count++;
- userid = i;
- }
- }
- }
- }
- if(!count) return RETURN_USER_FAILURE;
- if(count > 1) return RETURN_USER_MULTIPLE;
- return userid;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(strcmp(cmdtext, "/bangpci", true) == 0)
- {
- new tmp[36], idx;
- strtok(cmdtext, idx);
- if(!strlen(tmp))
- {
- SendClientMessage(playerid, -1, "{33CCFF}USAGE:{FFFFFF} /bangpci {D15401}[ID du joueur] [Raison]");
- return 1;
- }
- new joueur = ReturnUser(tmp);
- if(!IsPlayerConnected(joueur))
- {
- SendClientMessage(playerid, -1, "{FF0000}[Erreur]{FFFFFF} Ce joueur n'est pas connecté !");
- return 1;
- }
- new raison[126];
- raison = strtok(cmdtext, idx);
- if(!strlen(raison))
- {
- SendClientMessage(playerid, -1, "{33CCFF}USAGE:{FFFFFF} /bangpci [ID du joueur] {D15401}[Raison]");
- return 1;
- }
- new adminname[MAX_PLAYER_NAME+1];
- GetPlayerName(playerid, adminname, MAX_PLAYER_NAME+1);
- BanGPCI(joueur, adminname, raison);
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement