SA-MP Forums Archive
Errors with plates.. - 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 with plates.. (/showthread.php?tid=204852)



Errors with plates.. - Darklom - 30.12.2010

Not sure what's wrong,c an anyone help?

pawn Код:
if(strcmp(cmd, "/plate", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!IsAtDealership(playerid))
            {
                return 1;
            }
            if(!strlen(tmp))
            {
            if(PlayerToPoint(3.0, playerid,2130.7195,-1147.0983,24.3918))
            new length = strlen(cmdtext);  // 24559
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            idx++;
            if(!strlen(result)) return SendClientMessage(playerid, COLOR_GREY, "USE: {AA3333}/plate{AFAFAF} [plate number]");
            SetVehicleNumberPlate(GetPlayerVehicleID(playerid), result);
        } //24575
        return 1;
    }
}
Код:
(24559) : error 003: declaration of a local variable must appear in a compound block
(24559) : error 017: undefined symbol "length"
(24560) : error 017: undefined symbol "length"
(24566) : error 017: undefined symbol "length""



Re: Errors with plates.. - FUNExtreme - 30.12.2010

Well the error for line 24575 is pretty simple to fix. Add a ; at the end of line 24574, you forgot it


Re: Errors with plates.. - c-middia - 30.12.2010

SetVehicleNumberPlate(GetPlayerVehicleID(playerid) , result);// <
and you need to have made a variable called length, ie: new length;


Re: Errors with plates.. - Darklom - 30.12.2010

pawn Код:
new length = strlen(cmdtext);  // 24559
I did


Re: Errors with plates.. - blackwave - 30.12.2010

use dcmd insteas strcmp... Looks how is that easier ( I use this command on my server):
pawn Код:
dcmd_plate(playerid,params[])
{
   
   new ID = GetPlayerVehicleID(playerid);
   new string[128];
   if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, azul, "You're not in a vehicle");
   if(!strlen(params)) return SendClientMessage(playerid, azul, "Usage: /plate <number/name>");
   else
   {
       SetVehicleNumberPlate(ID, params);
       SetVehicleToRespawn(ID);
       format(string,sizeof(string),"{F216FA}You've changed your{00EEFF} VehicleID: {D9FA00}%d {FAD900}plate's for: {00FF88}%s",GetVehicleModel(ID),params);
       SendClientMessage(playerid, vermelho, string);
       PlayerPlaySound(playerid, 1133, 0.0, 0.0, 0.0);
   }
   return 1;
}
on OnPlayerCommandText add the line:
pawn Код:
dcmd(plate,5,cmdtext);



Re: Errors with plates.. - Hiddos - 30.12.2010

pawn Код:
if(strcmp(cmd, "/plate", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!IsAtDealership(playerid))
            {
                return 1;
            }
            if(!strlen(tmp))
            {
            if(PlayerToPoint(3.0, playerid,2130.7195,-1147.0983,24.3918)) //You're using if
            new length = strlen(cmdtext); //But not adding a bracket! (' { ')
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            idx++;
            if(!strlen(result)) return SendClientMessage(playerid, COLOR_GREY, "USE: {AA3333}/plate{AFAFAF} [plate number]");
            SetVehicleNumberPlate(GetPlayerVehicleID(playerid), result);
        } //24575
        return 1;
    }
}
So:

pawn Код:
if(blabla)
{
  morebla();
}
return;



Re: Errors with plates.. - Darklom - 30.12.2010

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/plate", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!IsAtDealership(playerid))
            {
                return 1;
            }
            if(!strlen(tmp))
            {
            if(PlayerToPoint(3.0, playerid,2130.7195,-1147.0983,24.3918)) //You're using if
            new length = strlen(cmdtext); //But not adding a bracket! (' { ')
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            idx++;
            if(!strlen(result)) return SendClientMessage(playerid, COLOR_GREY, "USE: {AA3333}/plate{AFAFAF} [plate number]");
            SetVehicleNumberPlate(GetPlayerVehicleID(playerid), result);
        } //24575
        return 1;
    }
}
So:

pawn Код:
if(blabla)
{
  morebla();
}
return;
Undefined symbol length about three times, if you fix that I'm going to add price maybe $2000 to change your license plates.