Mind-blowing unknown command problem
#1

Hi everyone
I have got a problem with my command in filterscript :
(In OnPlayerCommandText)
Код:
dcmd(buycar, 6, cmdtext);
This command should spawn car for some money (names and money is in big arrays - I am sure they are all right)
Код:
dcmd_buycar(playerid, params[]){
		tobuy = strval(params);
	
		if(strlen(params) == 0){
			SendPlayerText(playerid,"This vehicle does not exist. Usage /buycar [vehicleid].", COLOR_ERROR);
			return 1;
		}else{	
		new menutitle[200];
		format(menutitle,sizeof(menutitle), "Buy %s for %i ?",Vnames[tobuy],GetPrice(tobuy));
		BuyAsk = CreateMenu(menutitle, 1, 200.0, 150.0, 400.0, 400.0);
		AddMenuItem(BuyAsk, 0, "Yes");
		AddMenuItem(BuyAsk, 0, "No");
		Pnumber[playerid] = tobuy;
		ShowMenuForPlayer(BuyAsk,playerid);
		return 1;	
		}
    
}
Code of menu :
Код:
public OnPlayerSelectedMenuRow(playerid, row){
        new Menu:CurrentMenu = GetPlayerMenu(playerid);
       

        if(CurrentMenu == BuyAsk){
    		switch(row){
        		case 0:{//Yes
        			BuyVehicleProcess(playerid);
        			Pnumber[playerid] = 0;
        		}
        		case 1: //No
        		{
          			Pnumber[playerid] = 0;
        		}
			}
 
		}
        
        return 1;
}
And finally BuyVehicleProcess method :
Код:
BuyVehicleProcess(playerid){
				new playermoney = GetPlayerMoney(playerid);
        		new carprice = GetPrice(Pnumber[playerid]);
        		
        		if(carprice == 0){
        			SendPlayerText(playerid,"You can not buy this vehicle.", COLOR_ERROR);
					return 1;
        		}
        		
        		if (GetPlayerVehicleID(playerid) != 0) {
					SendPlayerText(playerid,"You are in vehicle.", COLOR_ERROR);
					return 1;
				}
				
				if(playermoney >= carprice)	{
					new Float:x, Float:y, Float:z, Float:angle;
       				GetPlayerPos(playerid, x, y, z);
        			GetPlayerFacingAngle(playerid, angle);
					playermoney = playermoney - carprice;
					ResetPlayerMoney(playerid);
					GivePlayerMoney(playerid,playermoney);
					new carid = CreateVehicle(Pnumber[playerid],x,y,z,angle,random(126),random(126),99999999999999999); // To not disappear
					PutPlayerInVehicle(playerid, carid, 0);
					return 1;
				}else{
					SendPlayerText(playerid,"You do not have enough money!", COLOR_ERROR);
					return 1;
				}
				
}
My problem is : When I use command "/buycar" (or even "/buycar " (with space)) it says "This vehicle does not exist. Usage /buycar [vehicleid]." (still OK)
But when I type for example "/buycar 400" it say Unknown command. I have tried everything and it wont work !
(I can ****** but I didnt find anythig)
Please help !
(Sorry for my English)

Then I wanted to add text recognition method so I can type /buycar Stretch, so I will be grateful for all your help.
Reply
#2

Thanks for quick response I will try now.
/Edit :
Thanks a lot ! Problem was in format method at the start (but I still dont know why) I will change and see.
Reply
#3

Also, when you put DCMD's you can't put them in order like you put the strcmp, you need to put it at beginning of the line ( just a tip )
Reply
#4

Quote:
Originally Posted by Mean
Посмотреть сообщение
Also, when you put DCMD's you can't put them in order like you put the strcmp, you need to put it at beginning of the line ( just a tip )
Sorry I didnt get it... (my english is not so advanced)
But I found my problem :
Код:
format(menutitle,sizeof(menutitle), "Buy %s for %i ?",Vnames[tobuy],GetPrice(tobuy));
The string part is wrong.
So...
How I must declare an array with strings and call it ?
I have :
Код:
new Vnames[212][25] = {
{"Landstalker"},{"Bravura"},{"Buffalo"},{"Linerunner"},{"Perrenial"},{"Sentinel"},{"Dumper"},
{"Firetruck"},{"Trashmaster"},(...)
Is it OK ? I have never get that string things in pawn...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)