//This is in the section onplayercommandtext
if (GangCreate[playerid] == 1) {
if (strlen(text)<40) {//check strlen
if (CheckGName(text) == 1) {//THIS IS WHERE THE PROBLEM IS(im very sure) here is where i check that there are no bad characters in my gang names
SendClientMessage(playerid,COLOR_RED,"Invalid Character Detected, please try again");
GangCreate[playerid] = 1;//give you another chance to make your gang
return 0;
}
GangCreate[playerid] = 0;
new txt[256];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
new a[45]; // This will be used as a filename
format(a,sizeof(a),"%s-gang",text);
if (dini_Exists(udb_encode(a))) { // checks if gang already exists
SendClientMessage(playerid,COLOR_RED,"This gang has already been made");
GangCreate[playerid] = 1;
return 0;
}
if (!dini_Exists(udb_encode("GANG_IDS"))) { //creates this file
dini_Create(udb_encode("GANG_IDS"));
dini_IntSet(udb_encode("GANG_IDS"),"GANGS",0);
}
new gid;
gid = GetGangID();
Gang[playerid] = 1;
GetPlayerName(playerid,pname,sizeof(pname));
dini_IntSet(udb_encode(pname),"Gang",1);
format(txt,sizeof(txt),"SYSTEM: GANG: %s has been created by %s",text,pname); //Tells everyone the gang has been made
SendClientMessageToAll(COLOR_WHITE,txt);
dini_Create(udb_encode(a)); //creates the main gang file
dini_Set(udb_encode(a),"LEADER",pname);
dini_IntSet(udb_encode(a),"GBANK",0);
dini_IntSet(udb_encode(a),"MEMBERS",1);
dini_IntSet(udb_encode(a),"GANGID",gid);
new b[20];
format(b,sizeof(b),"%d",gid);
dini_Set(udb_encode("GANG_IDS"),b,text); //where i store info on members and gangs
if (!dini_Exists(udb_encode("Info_Gangs_Members"))) {
dini_Create(udb_encode("Info_Gangs_Members"));
}
dini_Set(udb_encode("Info_Gangs_Members"), pname, text);
dini_IntSet(udb_encode(pname),"GangID",gid);
new testgangids;
testgangids = CheckOnlineGangs();
OnlineGangs[testgangids] = dini_Int(udb_encode(playername),"GangID"); //finds a gap in the online gangs (this definatly works)
SendClientMessage(playerid,COLOR_GREEN,"Gang Successfully Created");
return 0;
} else {
SendClientMessage(playerid,COLOR_RED,"This name is too long");
return 0;
}
}
//--------------------------------------------------------------------------
//This next bit is my CheckCharacter as named in the above code (near top)
//--------------------------------------------------------------------------
public CheckGName(text[]) {
new size;
size = 40;
for(new i=0; i< size; i++) { //loop
if (text[i]=='!') { //what im checking
return 1; //returns 1 so that script can tell its a bad character to stop impending server crash
}
if (text[i]=='£') {
return 1;
}
if (text[i]=='$') {
return 1;
}
if (text[i]=='%') {
return 1;
}
if (text[i]=='^') {
return 1;
}
if (text[i]=='&') {
return 1;
}
if (text[i]=='*') {
return 1;
}
if (text[i]=='|') {
return 1;
}
if (text[i]=='/') {
return 1;
}
if (text[i]=='?') {
return 1;
}
if (text[i]=='@') {
return 1;
}
if (text[i]=='~') {
return 1;
}
if (text[i]=='#') {
return 1;
}
if (text[i]==']') {
return 1;
}
if (text[i]=='[') {
return 1;
}
if (text[i]=='}') {
return 1;
}
if (text[i]=='{') {
return 1;
}
if (text[i]==''') {
return 1;
}
if (text[i]==';') {
return 1;
}
if (text[i]==':') {
return 1;
}
if (text[i]=='<') {
return 1;
}
if (text[i]=='>') {
return 1;
}
if (text[i]=='`') {
return 1;
}
if (text[i]=='¬') {
return 1;
}
if (text[i]=='-') {
return 1;
}
if (text[i]=='=') {
return 1;
}
if (text[i]=='+') {
return 1;
}
}
return 0; //its ok
}