/addcar - when i do it i get "Unknown Command"
#1

pawn Code:
if(!strcmp(cmdtext,"/addcar",true))
    {
      if(IsPlayerAdmin(playerid))
      {
            new Car;
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new CarModel=strval(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new CarColor1=strval(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new CarColor2=strval(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
//          new CarPrice=strval(tmp);
//          tmp = strtok(cmdtext, idx);
//          if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
//          new CarDescription[128];
//          if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new Float:CarX,Float:CarY,Float:CarZ,Float:CarA;
            GetPlayerPos(playerid,CarX,CarY,CarZ);
            GetPlayerFacingAngle(playerid,CarA);
            CarInfo[Car][cModel]=CarModel;
            CarInfo[Car][cX]=CarX;
            CarInfo[Car][cY]=CarY;
            CarInfo[Car][cZ]=CarZ;
            CarInfo[Car][cA]=CarA;
            CarInfo[Car][cColor1]=CarColor1;
            CarInfo[Car][cColor2]=CarColor2;
            CarInfo[Car][cOwned]=0;
//          CarInfo[Car][cOwner]=
//          CarInfo[Car][cDescription]=CarDescription
//          CarInfo[Car][cPrice]=CarPrice;
            CarInfo[Car][cLock]=0;
            CarInfo[Car][cResTime]=999999;
            CreateVehicle(CarInfo[Car][cModel],CarInfo[Car][cX],CarInfo[Car][cY],CarInfo[Car][cZ],CarInfo[Car][cA],CarInfo[Car][cColor1],CarInfo[Car][cColor2],CarInfo[Car][cResTime]);
            SaveCars(Car);
        return 1;
        }
        else return SendClientMessage(playerid,GREY,"Attempt Denied, You are not an Administrator!");
    }
Can someone tell me whats wrong with it?
Reply
#2

Quote:
Originally Posted by Castle
pawn Code:
if(!strcmp(cmdtext,"/addcar",true))
    {
      if(IsPlayerAdmin(playerid))
      {
            new Car;
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new CarModel=strval(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new CarColor1=strval(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new CarColor2=strval(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
//          new CarPrice=strval(tmp);
//          tmp = strtok(cmdtext, idx);
//          if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
//          new CarDescription[128];
//          if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new Float:CarX,Float:CarY,Float:CarZ,Float:CarA;
            GetPlayerPos(playerid,CarX,CarY,CarZ);
            GetPlayerFacingAngle(playerid,CarA);
            CarInfo[Car][cModel]=CarModel;
            CarInfo[Car][cX]=CarX;
            CarInfo[Car][cY]=CarY;
            CarInfo[Car][cZ]=CarZ;
            CarInfo[Car][cA]=CarA;
            CarInfo[Car][cColor1]=CarColor1;
            CarInfo[Car][cColor2]=CarColor2;
            CarInfo[Car][cOwned]=0;
//          CarInfo[Car][cOwner]=
//          CarInfo[Car][cDescription]=CarDescription
//          CarInfo[Car][cPrice]=CarPrice;
            CarInfo[Car][cLock]=0;
            CarInfo[Car][cResTime]=999999;
            CreateVehicle(CarInfo[Car][cModel],CarInfo[Car][cX],CarInfo[Car][cY],CarInfo[Car][cZ],CarInfo[Car][cA],CarInfo[Car][cColor1],CarInfo[Car][cColor2],CarInfo[Car][cResTime]);
            SaveCars(Car);
        return 1;
        }
        else return SendClientMessage(playerid,GREY,"Attempt Denied, You are not an Administrator!");
    }
Can someone tell me whats wrong with it?
Use dcmd and sscanf, it's most likely all that unused crap.
Reply
#3

Quote:
Originally Posted by Norn
Quote:
Originally Posted by Castle
pawn Code:
if(!strcmp(cmdtext,"/addcar",true))
    {
      if(IsPlayerAdmin(playerid))
      {
            new Car;
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new CarModel=strval(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new CarColor1=strval(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new CarColor2=strval(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
//          new CarPrice=strval(tmp);
//          tmp = strtok(cmdtext, idx);
//          if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
//          new CarDescription[128];
//          if(!strlen(tmp)){ return SendClientMessage(playerid, GREY,"USAGE: /addcar [ModelID] [Color1] [Color2] [Price] [Description]");}
            new Float:CarX,Float:CarY,Float:CarZ,Float:CarA;
            GetPlayerPos(playerid,CarX,CarY,CarZ);
            GetPlayerFacingAngle(playerid,CarA);
            CarInfo[Car][cModel]=CarModel;
            CarInfo[Car][cX]=CarX;
            CarInfo[Car][cY]=CarY;
            CarInfo[Car][cZ]=CarZ;
            CarInfo[Car][cA]=CarA;
            CarInfo[Car][cColor1]=CarColor1;
            CarInfo[Car][cColor2]=CarColor2;
            CarInfo[Car][cOwned]=0;
//          CarInfo[Car][cOwner]=
//          CarInfo[Car][cDescription]=CarDescription
//          CarInfo[Car][cPrice]=CarPrice;
            CarInfo[Car][cLock]=0;
            CarInfo[Car][cResTime]=999999;
            CreateVehicle(CarInfo[Car][cModel],CarInfo[Car][cX],CarInfo[Car][cY],CarInfo[Car][cZ],CarInfo[Car][cA],CarInfo[Car][cColor1],CarInfo[Car][cColor2],CarInfo[Car][cResTime]);
            SaveCars(Car);
        return 1;
        }
        else return SendClientMessage(playerid,GREY,"Attempt Denied, You are not an Administrator!");
    }
Can someone tell me whats wrong with it?
Use dcmd and sscanf, it's most likely all that unused crap.
Un-Used crap such as?
Reply
#4

Sorry i ment to say overused, i ment all the strtok's.

By the way car will always be 0 so your not really adding a new car but overwriting an existing, you need to assign a new id to it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)