SA-MP Forums Archive
Errors, help me please - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Errors, help me please (/showthread.php?tid=245223)



Errors, help me please - duckie - 30.03.2011

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);



Re: Errors, help me please - xir - 30.03.2011

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;
}



Re: Errors, help me please - iJumbo - 30.03.2011

Click me!


Re: Errors, help me please - duckie - 30.03.2011

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;
    }



Re: Errors, help me please - xir - 30.03.2011

You can add it at the buttom of your script


Re: Errors, help me please - duckie - 30.03.2011

Thank you, No errors or warnings.

good work guys!