/addcar - when i do it i get "Unknown Command" - 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: /addcar - when i do it i get "Unknown Command" (
/showthread.php?tid=130259)
/addcar - when i do it i get "Unknown Command" -
Castle - 26.02.2010
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?
Re: /addcar - when i do it i get "Unknown Command" -
Norn - 26.02.2010
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.
Re: /addcar - when i do it i get "Unknown Command" -
Castle - 26.02.2010
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?
Re: /addcar - when i do it i get "Unknown Command" -
Norn - 26.02.2010
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.