/adv command help!
#7

Add this at OnPlayerCommandText:
pawn Код:
new tmp[ 128 ], cmd[128], idx;
cmd = strtok( cmdtext, idx );
The Command:
pawn Код:
if( !strcmp( cmd, "/adv" ) )
{
    new str[ 256 char ];
    tmp = strtok( cmdtext, idx );
    if(!strlen(tmp)) return SendClientMessage(playerid, -1, "Use /adv [message");
    if(!IsPlayerInRangeOfPoint(playerid, RANGE, posX, posY, posZ)) return SendClientMessage(playerid, -1, "You arent in the spot to use this command!");
    if(GetPlayerMoney(playerid) < 70) return SendClientMessage(playerid, -1, "You don't have enough money !");

    format( str, sizeof str, "<<[ADVERT] %s>>", tmp );
    SendClientMessageToAll(-1, params[0]);
    GivePlayerMoney(playerid, -70);
    return 1;
}
And this is the Function:
pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
 
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply


Messages In This Thread
/adv command help! - by Panormitis - 05.10.2011, 10:23
Re: /adv command help! - by Pharrel - 05.10.2011, 10:28
Re: /adv command help! - by Panormitis - 05.10.2011, 10:30
Re: /adv command help! - by aRoach - 05.10.2011, 10:30
Re: /adv command help! - by Panormitis - 05.10.2011, 10:32
Re: /adv command help! - by Panormitis - 05.10.2011, 10:44
Re: /adv command help! - by aRoach - 05.10.2011, 10:56
Re: /adv command help! - by Jack_Leslie - 05.10.2011, 10:56

Forum Jump:


Users browsing this thread: 7 Guest(s)