SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 26/02/2010, 01:22 AM   #1
Castle
Huge Clucker
 
Castle's Avatar
 
Join Date: Aug 2008
Posts: 331
Reputation: 0
Default /addcar - when i do it i get "Unknown Command"

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?
__________________
Castle is offline  
Old 26/02/2010, 01:30 AM   #2
Norn
High-roller
 
Norn's Avatar
 
Join Date: Jul 2008
Location: Northern Ireland
Posts: 2,265
Reputation: 206
Default Re: /addcar - when i do it i get "Unknown Command"

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.
__________________
Pursuing other endeavours.

Skype: datinvictusguy
Norn is offline  
Old 26/02/2010, 01:40 AM   #3
Castle
Huge Clucker
 
Castle's Avatar
 
Join Date: Aug 2008
Posts: 331
Reputation: 0
Default Re: /addcar - when i do it i get "Unknown Command"

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?
__________________
Castle is offline  
Old 26/02/2010, 01:41 AM   #4
Norn
High-roller
 
Norn's Avatar
 
Join Date: Jul 2008
Location: Northern Ireland
Posts: 2,265
Reputation: 206
Default Re: /addcar - when i do it i get "Unknown Command"

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.
__________________
Pursuing other endeavours.

Skype: datinvictusguy
Norn is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Unknown Command" when server reaches close to 20 players? Outbreak Help Archive 51 02/03/2011 07:20 PM
2 Commands returning "SERVER: Unknown command" _Vortex Help Archive 6 08/01/2010 07:38 PM
commands works but also returns "unknown command" Coolman12 Help Archive 9 11/04/2009 03:03 PM


All times are GMT. The time now is 03:27 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.