Help /advert
#1

I tried to make it not to put this number in / advert.
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;
}
so that gave this error:

Код:
symbol already defined: "IsNumeric"
Anybody know how to solve?
Reply
#2

Delete the IsNumeric stock out of your script
Reply
#3

So that there will not be able to prevent the use of numbers in / advert.

how can I prevent the use of numbers in it?
Reply
#4

Quote:
Originally Posted by keller012
Посмотреть сообщение
So that there will not be able to prevent the use of numbers in / advert.

how can I prevent the use of numbers in it?
The "IsNumeric" is already a defined function I think. Delete the "IsNumeric stock".
Reply
#5

as mikkelgutten said Lemme explain better

DELETE THIS FROM YOUR SCRIPT [ THE ONE YOU POSTED]

pawn Код:
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;
}
Reply
#6

As I said "IsNumeric" is already a defined function in "a_samp".

You can read about it at: https://sampwiki.blast.hk/wiki/Useful_Functions#IsNumeric
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)