09.07.2010, 17:02
I tried to make it not to put this number in / advert.
I did this:
so that gave this error:
Anybody know how to solve?
I did this:
Код:
if(strcmp(cmd, "/advert", true) == 0 || strcmp(cmd, "/ad", true) == 0) { if(IsPlayerConnected(playerid)) { if(gPlayerLogged[playerid] == 0) { SendClientMessage(playerid, COLOR_GREY, " You need to login first!"); return 1; } if(PlayerInfo[playerid][pLevel] < 2) { SendClientMessage(playerid, COLOR_GREY, " You need level 2 to use this feature!"); return 1; } if(IsNumeric(result)) { SendClientMessage(playerid, COLOR_GREY, " is forbidden to use the numbers / ad !"); return 1; } GetPlayerName(playerid, sendername, sizeof(sendername)); new length = strlen(cmdtext); while ((idx < length) && (cmdtext[idx] <= ' ')) { idx++; } new offset = idx; new result[64]; while ((idx < length) && ((idx - offset) < (sizeof(result) - 1))) { result[idx - offset] = cmdtext[idx]; idx++; } result[idx - offset] = EOS; if(!strlen(result)) { SendClientMessage(playerid, COLOR_GRAD2, "USE: (/ad)vert [txt]"); return 1; } if ((!adds) && (PlayerInfo[playerid][pAdmin] < 1)) { format(string, sizeof(string), " Please try again later, wait %d seconds between advertisements!", (addtimer/1000)); SendClientMessage(playerid, COLOR_GRAD2, string); return 1; } new payout = idx * 5; if(GetPlayerMoney(playerid) < payout) { format(string, sizeof(string), "* You have used% d characters that costs $ %d, you do not have enough money.", offset, payout); SendClientMessage(playerid, COLOR_WHITE, string); return 1; } SafeGivePlayerMoney(playerid, - payout); SBizzInfo[7][sbTill] += payout; ExtortionSBiz(7, payout); format(string, sizeof(string), "Advert: %s, Contact: %s Tel: %d",result, sendername, PlayerInfo[playerid][pPnumber]); OOCNews(TEAM_GROVE_COLOR,string); format(string, sizeof(string), "~r~paid $%d~n~~w~The ad contains:% d characters", payout, idx); GameTextForPlayer(playerid, string, 5000, 1); if (PlayerInfo[playerid][pAdmin] < 1){SetTimer("AddsOn", addtimer, 0);adds = 0;} } return 1; }
Код:
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]!='+') || (string[i]=='-' && i!=0) // || (string[i]=='+' && i!=0) // ) return false; } if (length==1 && (string[0]=='-' || string[0]=='+')) return false; return true; }
Код:
symbol already defined: "IsNumeric"