SA-MP Forums Archive
need help with this code - 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)
+--- Thread: need help with this code (/showthread.php?tid=447589)



need help with this code - horsemeat - 30.06.2013

well the title says it all here you go

pawn Код:
stock CreatePlate(vehicleid)
{
    topofcreateplate:
    new pstring[128];
    format(pstring,sizeof(pstring),"%s",RandomizePlate(vehicleid));
    if(PlateExist(pstring))
    {
        goto topofcreateplate;
    }
    SetVehicleNumberPlate(vehicleid,pstring);
    format(existplate[existplatecount],sizeof(existplate),"%s",pstring);
    existplatecount ++;
    return pstring;
}
stock PlateExist(platestring)
{
    for(new count;count < existplatecount;count++)
    {
        if(strcmp(existplate[count],platestring,true,7)==0)
        {
            return true;
        }
    }
    return false;
}
stock RandomizePlate(vehicleid)
{
    new platestring[128];
    for(new platecount;platecount < 7;platecount++)
    {
        if((platecount)==3)
        {
            new addplatestring[128];
            format(addplatestring,sizeof(addplatestring),"%s",platestring);
            format(platestring,sizeof(platestring),"%s ",addplatestring);
            continue;
        }
        new rand = random(1);
        if((rand)==0)
        {
            rand = random(9);
            if(isnull(platestring))
            {
                format(platestring,sizeof(platestring),"%i",rand);
            }
            else
            {
                new addplatestring[128];
                format(addplatestring,sizeof(addplatestring),"%s",platestring);
                format(platestring,sizeof(platestring),"%s%i",addplatestring,rand);
            }
        }
        else if((rand)==1)
        {
            rand = random(25);
            if(isnull(platestring))
            {
                format(platestring,sizeof(platestring),"%c",randomletters[rand]);
            }
            else
            {
                new addplatestring[128];
                format(addplatestring,sizeof(addplatestring),"%s",platestring);
                format(platestring,sizeof(platestring),"%s%c",addplatestring,randomletters[rand]);
            }
        }
    }
    return platestring;
}
some error code
Код:
C:\Users\joshua\Desktop\sampserver\filterscripts\jbcars.pwn(6206) : error 035: argument type mismatch (argument 1)
C:\Users\joshua\Desktop\sampserver\filterscripts\jbcars.pwn(6219) : error 035: argument type mismatch (argument 2)
C:\Users\joshua\Desktop\sampserver\filterscripts\jbcars.pwn(6215) : warning 203: symbol is never used: "platestring"
C:\Users\joshua\Desktop\sampserver\filterscripts\jbcars.pwn(6226) : warning 203: symbol is never used: "vehicleid"
C:\Users\joshua\Desktop\sampserver\filterscripts\jbcars.pwn(8626) : warning 203: symbol is never used: "carlisenceplate"



Re: need help with this code - MP2 - 30.06.2013

How are we meant to know which lines the errors are on..?


Re: need help with this code - Scottas - 30.06.2013

first,
Код:
stock PlateExist(platestring)
platestring should be an array:
Код:
stock PlateExist(platestring[])



Re: need help with this code - horsemeat - 30.06.2013

Quote:
Originally Posted by Scottas
Посмотреть сообщение
first,
Код:
stock PlateExist(platestring)
platestring should be an array:
Код:
stock PlateExist(platestring[])
Thanks


Re: need help with this code - Vince - 30.06.2013

Don't use goto! My god. Never heard of do-while loops, have you?

pawn Код:
new pstring[128];

    do format(pstring,sizeof(pstring),"%s",RandomizePlate(vehicleid));
    while(PlateExist(pstring));

    SetVehicleNumberPlate(vehicleid,pstring);