13.12.2010, 16:02
Hi everyone
I have got a problem with my command in filterscript :
(In OnPlayerCommandText)
This command should spawn car for some money (names and money is in big arrays - I am sure they are all right)
Code of menu :
And finally BuyVehicleProcess method :
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.
I have got a problem with my command in filterscript :
(In OnPlayerCommandText)
Код:
dcmd(buycar, 6, cmdtext);
Код:
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; } }
Код:
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; }
Код:
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; } }
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.