Errors, help me please
#1

E:\simple DM\filterscripts\CarSystemV1.0.pwn(159) : error 017: undefined symbol "strtok"
E:\simple DM\filterscripts\CarSystemV1.0.pwn(159) : error 033: array must be indexed (variable "cmd")
E:\simple DM\filterscripts\CarSystemV1.0.pwn(15 : warning 203: symbol is never used: "idx"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase

this is the error

This are the lines:
pawn Код:
new cmd[256], vehicleid = GetPlayerVehicleID(playerid), v = GetPlayerVehicleID(playerid), idx, str[256];
cmd = strtok(cmdtext, idx);
Reply
#2

add this to your script

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
#3

Click me!
Reply
#4

Quote:
Originally Posted by xir
Посмотреть сообщение
add this to your script

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;
}
Where should i add it?
ive got this:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

    new cmd[256], vehicleid = GetPlayerVehicleID(playerid), v = GetPlayerVehicleID(playerid), idx, str[256];
    cmd = strtok(cmdtext, idx);
    if(!strcmp(cmd,"/BuyCar",true))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,red,"You are not in a vehicle");
        if(dini_Int(CarFile(vehicleid),"Owned")==1) return SendClientMessage(playerid,red," this car is already owned.");
        if(dini_Int(CarFile(vehicleid),"Public")==1) return SendClientMessage(playerid,red," this car is unbuyable ");
        if(dini_Int(PFile(playerid),"GotCar")==1) return SendClientMessage(playerid,red,"you already have a car ");
        if(GetPlayerMoney(playerid) < 200000) return SendClientMessage(playerid,red,"You dont have the money (200000$)");
        if(!dini_Exists(PFile(playerid)))
        {
            dini_Create(PFile(playerid));
            dini_IntSet(PFile(playerid),"GotCar",1);
            dini_IntSet(PFile(playerid),"CarId",vehicleid);
        }
        else if(dini_Exists(PFile(playerid)))
        {
            dini_IntSet(PFile(playerid),"GotCar",1);
            dini_IntSet(PFile(playerid),"CarId",vehicleid);
        }
        if(!dini_Exists(CarFile(vehicleid)))
        {
            dini_Create(CarFile(vehicleid));
            dini_Set(CarFile(vehicleid),"Owner",Gn(playerid));
            dini_IntSet(CarFile(vehicleid),"Owned",1);
        }
        else if(dini_Exists(CarFile(vehicleid)))
        {
            dini_Set(CarFile(vehicleid),"Owner",Gn(playerid));
            dini_IntSet(CarFile(vehicleid),"Owned",1);
        }
        format(str,256,"You bought a new %s",VehNames[GetVehicleModel(vehicleid)-400]);
        SendClientMessage(playerid,green,str);
        PlayerPlaySound(playerid,1056,0.0,0.0,0.0);
        SendClientMessage(playerid,white,"To call your car use /CallCar");
        format(TextCar,sizeof(TextCar),"This car %s\nBelong To %s",VehNames[GetVehicleModel(v)-400],dini_Get(CarFile(v),"Owner"));
        Update3DTextLabelText(TextUpCar[vehicleid],colors[random(sizeof(colors))],TextCar);
        Attach3DTextLabelToVehicle(TextUpCar[vehicleid],vehicleid,0.0,0.0,0.0);
        GivePlayerMoney(playerid,-200000);
        return 1;
    }
Reply
#5

You can add it at the buttom of your script
Reply
#6

Thank you, No errors or warnings.

good work guys!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)