Convert to if strcmp instead of ZCMD
#3

For first, why do you want to change that, ZCMD is more faster than strcmp..
Whatever..

You need this 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;
}
Add this to the OnPlayerCommandText callback(at the beginning of the callback):
pawn Код:
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
The commands would be like this:
pawn Код:
if(!strcmp(cmd, "/addpickup", true))
{
    new tmp[128], pID, tID;
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFF,"USAGE: /AddPickup < Pickup ID > < Type >");
    pID = strval(tmp);
   
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFF,"USAGE: /AddPickup < Pickup ID > < Type >");
    tID = strval(tmp);
   
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    CreateSavedPickup(pID, tID, X, Y, Z);
    new Msg[128];
    format(Msg, sizeof Msg, "Pickup Successfully Created. (Model: %d) (Type: %d)", pID, tID);
    SendClientMessage(playerid, 0xFFFFFF, Msg);
    return 1;
}
pawn Код:
if(!strcmp(cmd, "/removepickup", true))
{
    new tmp[128], PickupID;
    if(!strlen(tmp)) return SendClientMessage(playerid, 0xFFFFFF,"USAGE: /RemovePickup < Pickup ID >");
    PickupID = strval(tmp);
   
    if(!IsValidDynamicPickup(pInfo[PickupID][PID])) return SendClientMessage(playerid, 0xFFFFFFF, "ERROR: Pickup Does Not Exist!");

    DestroyDynamicPickup(pInfo[PickupID][PID]);

    format(pFile, sizeof(pFile), PICKUPFILE, PickupID);
    if(dini_Exists(pFile))
    {
        dini_Remove(pFile);
        dini_IntSet(pIDFile, "Total Pickups:", dini_Int(pIDFile, "Total Pickups:")-1);
    }

    new Msg[128];
    format(Msg,sizeof(Msg),"Pickup ID: %d Was 1Destroyed!",PickupID);
    SendClientMessage(playerid, 0xFFFFFFF,Msg);
    return 1;
}
Reply


Messages In This Thread
Convert to if strcmp instead of ZCMD - by Stanford - 24.01.2013, 15:58
Re: Convert to if strcmp instead of ZCMD - by FUNExtreme - 24.01.2013, 17:01
Re: Convert to if strcmp instead of ZCMD - by Roach_ - 24.01.2013, 17:06

Forum Jump:


Users browsing this thread: 1 Guest(s)