Problem with strtok
#1

When i'm do this command, all the time its saying to me that:
usage: /vcreate bla bla bla bla ..
this is the command:
PHP код:
if(!strcmp(cmd,"/vcreate",true))
{
    if(
PDataBase[playerid][AdminLevel] <= 4) return SendClientMessage(playeridCOLOR_RED"[Error]: Access Denied [Level 4+]");
    new
        
Float:Pos[4],
        
/*ivPrice,
        ivModel,
        ivColors[2],*/
        
price[256],
        
color1[256],
        
color2[256],
        
iMsg[256];
    
price strtok(cmdtext,idx);
    
color1 strtok(cmdtext,idx);
    
color2 strtok(cmdtext,idx);
    if(!
strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"USE Way: /vCreate [Vehicle Model] [Price] [Color1] [Color2]");
    if(!
strlen(price)) return SendClientMessage(playerid,COLOR_WHITE,"USE Way: /vCreate [Vehicle Model] [Price] [Color1] [Color2]");
    if(!
strlen(color1)) return SendClientMessage(playerid,COLOR_WHITE,"USE Way: /vCreate [Vehicle Model] [Price] [Color1] [Color2]");
    if(!
strlen(color2)) return SendClientMessage(playerid,COLOR_WHITE,"USE Way: /vCreate [Vehicle Model] [Price] [Color1] [Color2]");
    
//if(sscanf(cmdtext, "iiii", ivModel, ivPrice, ivColors[0], ivColors[1])) return SendClientMessage(playerid, COLOR_WHITE,"USE Way: /vCreate [Vehicle Model] [Price] [Color1] [Color2]");
    
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]);
    
GetPlayerFacingAngle(playeridPos[3]);
    
Created++;
    
vInfo[Created][vModel]     = strval(tmp);
    
vInfo[Created][vColor1] = strval(color1);
    
vInfo[Created][vColor2] = strval(color2);
    
vInfo[Created][vPrice]     = strval(price);
    
vInfo[Created][vPosX] = Pos[0];
    
vInfo[Created][vPosY] = Pos[1];
    
vInfo[Created][vPosZ] = Pos[2];
    
vInfo[Created][vPosA] = Pos[3];
    
strmid(vInfo[Created][vOwner], "Unbought"0256);
    
strmid(vInfo[Created][vPlate], "ChangeME"0256);
    new
        
vFile[15];
    
format(vFilesizeof(vFile), "SERVER-Vehicles/%d.ini"Created);
    
dini_IntSet(vFile"Model"strval(tmp));
    
dini_IntSet(vFile"Color1"strval(color1));
    
dini_IntSet(vFile"Color2"strval(color2));
    
dini_IntSet(vFile"Price"strval(price));
    
dini_Set(vFile"Owner""Unbought");
    
dini_FloatSet(vFile"vPosX"Pos[0]);
    
dini_FloatSet(vFile"vPosY"Pos[1]);
    
dini_FloatSet(vFile"vPosZ"Pos[2]);
    
dini_FloatSet(vFile"vPosA"Pos[3]);
    
dini_Set(vFile"Plate""ChangeME");
    new
        
cCar CreateVehicle(strval(tmp), Pos[0], Pos[1], Pos[2], Pos[3], strval(color1), strval(color2), 500000);
    
SetVehicleNumberPlate(cCar"ChangeME");
    
ivCreated[cCar] = Created;
    
SavePrivVeh(Created);
    
format(iMsgsizeof(iMsg), ""#CYELLOW"[Info] Vehicle: "#CBLUE"%i (VID: %i) "#CYELLOW"has been created. Price: "#CBLUE"$%i "#CYELLOW"Plate: "#CBLUE"ChangeME", strval(tmp), Created, strval(price));
    
SendClientMessage(playeridCOLOR_WHITEiMsg);
    return 
1;

Reply
#2

You never store a value in tmp, assuming you want to store the first parameter of the command in tmp, then simply add this before the price strtok:

pawn Код:
tmp = strtok(cmdtext,idx);
I recommend using a command processor such as Y_CMD or ZCMD though.
Reply
#3

Oh, right I forgot that ..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)