[HELP] Command
#1

Hello everyone,

I'm currently trying to write a command however I get stuck with the following command.

In the compiler it doesn't give any errors but when you use the command to buy your first vehicle it outputs on the screen:
Код:
The seller gave you the keys...
SERVER: Unknow command
First I thought that the server somewhere returns a 0 but I can't find out what the problem is..

Код:
if(strcmp(cmd, "/buyvehicle", true) == 0) // By Kastranova
	{
	    if(IsPlayerConnected(playerid))
	    {
            new VehiclePrice, vehiclebuyid2;
			if(PlayerInfo[playerid][pPcarkey] != 999 && PlayerInfo[playerid][pPcarkey2] != 999 && PlayerInfo[playerid][pPcarkey3] != 999){
					SendClientMessage(playerid, COLOR_GREY, "You already own 3 vehicles");
					return 1;
				}
			if(PlayerToPoint(3.0, playerid, 2131.7634,-1150.3534,24.1660))
			    {
			    new vehiclebuyid[64];
			    vehiclebuyid = strtok(cmdtext, idx);
				new show = sizeof(buyablevehicles);
				if(strlen(vehiclebuyid) == 0){
					new show2 = show / 3;
					new vi;
					new vtext[256];
					for(new v; v<show2; v++){
						vi = v * 3;
						format(vtext, sizeof(vtext), "ID: %d - Name: %s, Price: %d$ | ID: %d - Name: %s, Price: %d$ | ID: %d - Name: %s, Price: %d$", buyablevehicles[vi][Model], buyablevehicles[vi][VName], buyablevehicles[vi][Price], buyablevehicles[vi+1][Model], buyablevehicles[vi+1][VName], buyablevehicles[vi+1][Price], buyablevehicles[vi+2][Model], buyablevehicles[vi+2][VName], buyablevehicles[vi+2][Price]);
						SendClientMessage(playerid, COLOR_YELLOW,vtext);
						}
					return 1;
					}
				vehiclebuyid2 = strval(vehiclebuyid);
				for(new v2=0; v2<show; v2++){
					if(buyablevehicles[v2][Model] == vehiclebuyid2){
						VehiclePrice = buyablevehicles[v2][Price];
						break;
						}
					}
				if(PlayerInfo[playerid][pCash] >= VehiclePrice){
				SafeGivePlayerMoney(playerid, -VehiclePrice);
				SendClientMessage(playerid, COLOR_RED, "Seller gave you keys from your new vehicle.");
				if(PlayerInfo[playerid][pPcarkey] == 999){
					idx = 192;
					while (idx < OwnableVehiclesAdded)
						{
	 					new string3[256];
						format(string3, sizeof(string3), "Cars/%d.ini", idx);
						if(!fexist(string3))
		    				{
						    // Setup some variables
						    CarInfo[idx][cModel] = vehiclebuyid2;
							CarInfo[idx][cLocationx] = 2120.8208;
							CarInfo[idx][cLocationy] = -1151.5223;
							CarInfo[idx][cLocationz] = 23.9849;
							CarInfo[idx][cAngle] = 358.9265;
							CarInfo[idx][cColorOne] = 1;
							CarInfo[idx][cColorTwo] = 1;
							new string4[256];
							GetPlayerName(playerid, string4, 256);
							format(CarInfo[idx][cOwner], 256, string4);
							format(CarInfo[idx][cDescription], 256, buyablevehicles[vehiclebuyid2][VName]);
							CarInfo[idx][cValue] = VehiclePrice;
							CarInfo[idx][cLicense] = idx;
							CarInfo[idx][cRegistration] = idx;
							CarInfo[idx][cOwned] = 1;
							CarInfo[idx][cLock] = 0;
							CarInfo[idx][cAlarm] = 0;
							CarInfo[idx][cMod1] = 0;
							CarInfo[idx][cMod2] = 0;
							CarInfo[idx][cMod3] = 0;
							CarInfo[idx][cMod4] = 0;
							CarInfo[idx][cMod5] = 0;
							CarInfo[idx][cMod6] = 0;
							CarInfo[idx][cMod7] = 0;
							CarInfo[idx][cMod8] = 0;
							CarInfo[idx][cMod9] = 0;
							CarInfo[idx][cMod10] = 0;
							CarInfo[idx][cMod11] = 0;
							CarInfo[idx][cMod12] = 0;
							CarInfo[idx][cMod13] = 0;
							CarInfo[idx][cMod14] = 0;
							CarInfo[idx][cMod15] = 0;
							CarInfo[idx][cMod16] = 0;
							CarInfo[idx][cMod17] = 0;
							new File: csFile = fopen(string3, io_write);
							if (csFile)
								{
				    			new var[64];
				    			format(var, 64, "Model=%d\n", CarInfo[idx][cModel]);fwrite(csFile, var);
								format(var, 64, "Locationx=%f\n",CarInfo[idx][cLocationx]);fwrite(csFile, var);
								format(var, 64, "Locationy=%f\n",CarInfo[idx][cLocationy]);fwrite(csFile, var);
								format(var, 64, "Locationz=%f\n",CarInfo[idx][cLocationz]);fwrite(csFile, var);
								format(var, 64, "Angel=%f\n",CarInfo[idx][cAngle]);fwrite(csFile, var);
								format(var, 64, "ColorOne=%d\n",CarInfo[idx][cColorOne]);fwrite(csFile, var);
								format(var, 64, "ColorTwo=%d\n",CarInfo[idx][cColorTwo]);fwrite(csFile, var);
								format(var, 64, "Owner=%s\n",CarInfo[idx][cOwner]);fwrite(csFile, var);
								format(var, 64, "Description=%s\n",CarInfo[idx][cDescription]);fwrite(csFile, var);
								format(var, 64, "Value=%d\n",CarInfo[idx][cValue]);fwrite(csFile, var);
								format(var, 64, "License=%d\n",CarInfo[idx][cLicense]);fwrite(csFile, var);
								format(var, 64, "Registration=%d\n",CarInfo[idx][cRegistration]);fwrite(csFile, var);
								format(var, 64, "Owned=%d\n",CarInfo[idx][cOwned]);fwrite(csFile, var);
								format(var, 64, "Lock=%d\n",CarInfo[idx][cLock]);fwrite(csFile, var);
								format(var, 64, "Alarm=%d\n",CarInfo[idx][cAlarm]);fwrite(csFile, var);
								format(var, 64, "Mod1=%d\n",CarInfo[idx][cMod1]);fwrite(csFile, var);
								format(var, 64, "Mod2=%d\n",CarInfo[idx][cMod2]);fwrite(csFile, var);
								format(var, 64, "Mod3=%d\n",CarInfo[idx][cMod3]);fwrite(csFile, var);
								format(var, 64, "Mod4=%d\n",CarInfo[idx][cMod4]);fwrite(csFile, var);
								format(var, 64, "Mod5=%d\n",CarInfo[idx][cMod5]);fwrite(csFile, var);
								format(var, 64, "Mod6=%d\n",CarInfo[idx][cMod6]);fwrite(csFile, var);
								format(var, 64, "Mod7=%d\n",CarInfo[idx][cMod7]);fwrite(csFile, var);
								format(var, 64, "Mod8=%d\n",CarInfo[idx][cMod8]);fwrite(csFile, var);
								format(var, 64, "Mod9=%d\n",CarInfo[idx][cMod9]);fwrite(csFile, var);
								format(var, 64, "Mod10=%d\n",CarInfo[idx][cMod10]);fwrite(csFile, var);
								format(var, 64, "Mod11=%d\n",CarInfo[idx][cMod11]);fwrite(csFile, var);
								format(var, 64, "Mod12=%d\n",CarInfo[idx][cMod12]);fwrite(csFile, var);
								format(var, 64, "Mod13=%d\n",CarInfo[idx][cMod13]);fwrite(csFile, var);
								format(var, 64, "Mod14=%d\n",CarInfo[idx][cMod14]);fwrite(csFile, var);
								format(var, 64, "Mod15=%d\n",CarInfo[idx][cMod15]);fwrite(csFile, var);
								format(var, 64, "Mod16=%d\n",CarInfo[idx][cMod16]);fwrite(csFile, var);
								format(var, 64, "Mod17=%d\n",CarInfo[idx][cMod17]);fwrite(csFile, var);
								fclose(csFile);
								}
							new carids;
							carids = CreateVehicle(CarInfo[idx][cModel],CarInfo[idx][cLocationx],CarInfo[idx][cLocationy],CarInfo[idx][cLocationz]+1.0,CarInfo[idx][cAngle],CarInfo[idx][cColorOne],CarInfo[idx][cColorTwo],60000);
							//ModVehicle(idx);
							PlayerInfo[playerid][pPcarkey] = carids;
						    idx = 9999;
						    }
							else
			    			{
						    idx++;
						    }
						}
					return 1;
					}
				if(PlayerInfo[playerid][pPcarkey2] == 999){
					
					return 1;
					}
				if(PlayerInfo[playerid][pPcarkey3] == 999){
					
					return 1;
					}
			    }
   			SendClientMessage(playerid, COLOR_RED, "You can not afford this vehicle right now, get more money.");
			return 1;
			}
		}
	}
I hope someone can help me out
Reply
#2

pawn Код:
if(strcmp(cmd, "/buyvehicle", true) == 0) // By Kastranova
    {
        if(IsPlayerConnected(playerid))
        {
            new VehiclePrice, vehiclebuyid2;
            if(PlayerInfo[playerid][pPcarkey] != 999 && PlayerInfo[playerid][pPcarkey2] != 999 && PlayerInfo[playerid][pPcarkey3] != 999){
                    SendClientMessage(playerid, COLOR_GREY, "You already own 3 vehicles");
                    return 1;
                }
            if(PlayerToPoint(3.0, playerid, 2131.7634,-1150.3534,24.1660))
                {
                new vehiclebuyid[64];
                vehiclebuyid = strtok(cmdtext, idx);
                new show = sizeof(buyablevehicles);
                if(strlen(vehiclebuyid) == 0){
                    new show2 = show / 3;
                    new vi;
                    new vtext[256];
                    for(new v; v<show2; v++){
                        vi = v * 3;
                        format(vtext, sizeof(vtext), "ID: %d - Name: %s, Price: %d$ | ID: %d - Name: %s, Price: %d$ | ID: %d - Name: %s, Price: %d$", buyablevehicles[vi][Model], buyablevehicles[vi][VName], buyablevehicles[vi][Price], buyablevehicles[vi+1][Model], buyablevehicles[vi+1][VName], buyablevehicles[vi+1][Price], buyablevehicles[vi+2][Model], buyablevehicles[vi+2][VName], buyablevehicles[vi+2][Price]);
                        SendClientMessage(playerid, COLOR_YELLOW,vtext);
                        }
                    return 1;
                    }
                vehiclebuyid2 = strval(vehiclebuyid);
                for(new v2=0; v2<show; v2++){
                    if(buyablevehicles[v2][Model] == vehiclebuyid2){
                        VehiclePrice = buyablevehicles[v2][Price];
                        break;
                        }
                    }
                if(PlayerInfo[playerid][pCash] >= VehiclePrice){
                SafeGivePlayerMoney(playerid, -VehiclePrice);
                SendClientMessage(playerid, COLOR_RED, "Seller gave you keys from your new vehicle.");
                if(PlayerInfo[playerid][pPcarkey] == 999){
                    idx = 192;
                    while (idx < OwnableVehiclesAdded)
                        {
                        new string3[256];
                        format(string3, sizeof(string3), "Cars/%d.ini", idx);
                        if(!fexist(string3))
                            {
                            // Setup some variables
                            CarInfo[idx][cModel] = vehiclebuyid2;
                            CarInfo[idx][cLocationx] = 2120.8208;
                            CarInfo[idx][cLocationy] = -1151.5223;
                            CarInfo[idx][cLocationz] = 23.9849;
                            CarInfo[idx][cAngle] = 358.9265;
                            CarInfo[idx][cColorOne] = 1;
                            CarInfo[idx][cColorTwo] = 1;
                            new string4[256];
                            GetPlayerName(playerid, string4, 256);
                            format(CarInfo[idx][cOwner], 256, string4);
                            format(CarInfo[idx][cDescription], 256, buyablevehicles[vehiclebuyid2][VName]);
                            CarInfo[idx][cValue] = VehiclePrice;
                            CarInfo[idx][cLicense] = idx;
                            CarInfo[idx][cRegistration] = idx;
                            CarInfo[idx][cOwned] = 1;
                            CarInfo[idx][cLock] = 0;
                            CarInfo[idx][cAlarm] = 0;
                            CarInfo[idx][cMod1] = 0;
                            CarInfo[idx][cMod2] = 0;
                            CarInfo[idx][cMod3] = 0;
                            CarInfo[idx][cMod4] = 0;
                            CarInfo[idx][cMod5] = 0;
                            CarInfo[idx][cMod6] = 0;
                            CarInfo[idx][cMod7] = 0;
                            CarInfo[idx][cMod8] = 0;
                            CarInfo[idx][cMod9] = 0;
                            CarInfo[idx][cMod10] = 0;
                            CarInfo[idx][cMod11] = 0;
                            CarInfo[idx][cMod12] = 0;
                            CarInfo[idx][cMod13] = 0;
                            CarInfo[idx][cMod14] = 0;
                            CarInfo[idx][cMod15] = 0;
                            CarInfo[idx][cMod16] = 0;
                            CarInfo[idx][cMod17] = 0;
                            new File: csFile = fopen(string3, io_write);
                            if (csFile)
                                {
                                new var[64];
                                format(var, 64, "Model=%d\n", CarInfo[idx][cModel]);fwrite(csFile, var);
                                format(var, 64, "Locationx=%f\n",CarInfo[idx][cLocationx]);fwrite(csFile, var);
                                format(var, 64, "Locationy=%f\n",CarInfo[idx][cLocationy]);fwrite(csFile, var);
                                format(var, 64, "Locationz=%f\n",CarInfo[idx][cLocationz]);fwrite(csFile, var);
                                format(var, 64, "Angel=%f\n",CarInfo[idx][cAngle]);fwrite(csFile, var);
                                format(var, 64, "ColorOne=%d\n",CarInfo[idx][cColorOne]);fwrite(csFile, var);
                                format(var, 64, "ColorTwo=%d\n",CarInfo[idx][cColorTwo]);fwrite(csFile, var);
                                format(var, 64, "Owner=%s\n",CarInfo[idx][cOwner]);fwrite(csFile, var);
                                format(var, 64, "Description=%s\n",CarInfo[idx][cDescription]);fwrite(csFile, var);
                                format(var, 64, "Value=%d\n",CarInfo[idx][cValue]);fwrite(csFile, var);
                                format(var, 64, "License=%d\n",CarInfo[idx][cLicense]);fwrite(csFile, var);
                                format(var, 64, "Registration=%d\n",CarInfo[idx][cRegistration]);fwrite(csFile, var);
                                format(var, 64, "Owned=%d\n",CarInfo[idx][cOwned]);fwrite(csFile, var);
                                format(var, 64, "Lock=%d\n",CarInfo[idx][cLock]);fwrite(csFile, var);
                                format(var, 64, "Alarm=%d\n",CarInfo[idx][cAlarm]);fwrite(csFile, var);
                                format(var, 64, "Mod1=%d\n",CarInfo[idx][cMod1]);fwrite(csFile, var);
                                format(var, 64, "Mod2=%d\n",CarInfo[idx][cMod2]);fwrite(csFile, var);
                                format(var, 64, "Mod3=%d\n",CarInfo[idx][cMod3]);fwrite(csFile, var);
                                format(var, 64, "Mod4=%d\n",CarInfo[idx][cMod4]);fwrite(csFile, var);
                                format(var, 64, "Mod5=%d\n",CarInfo[idx][cMod5]);fwrite(csFile, var);
                                format(var, 64, "Mod6=%d\n",CarInfo[idx][cMod6]);fwrite(csFile, var);
                                format(var, 64, "Mod7=%d\n",CarInfo[idx][cMod7]);fwrite(csFile, var);
                                format(var, 64, "Mod8=%d\n",CarInfo[idx][cMod8]);fwrite(csFile, var);
                                format(var, 64, "Mod9=%d\n",CarInfo[idx][cMod9]);fwrite(csFile, var);
                                format(var, 64, "Mod10=%d\n",CarInfo[idx][cMod10]);fwrite(csFile, var);
                                format(var, 64, "Mod11=%d\n",CarInfo[idx][cMod11]);fwrite(csFile, var);
                                format(var, 64, "Mod12=%d\n",CarInfo[idx][cMod12]);fwrite(csFile, var);
                                format(var, 64, "Mod13=%d\n",CarInfo[idx][cMod13]);fwrite(csFile, var);
                                format(var, 64, "Mod14=%d\n",CarInfo[idx][cMod14]);fwrite(csFile, var);
                                format(var, 64, "Mod15=%d\n",CarInfo[idx][cMod15]);fwrite(csFile, var);
                                format(var, 64, "Mod16=%d\n",CarInfo[idx][cMod16]);fwrite(csFile, var);
                                format(var, 64, "Mod17=%d\n",CarInfo[idx][cMod17]);fwrite(csFile, var);
                                fclose(csFile);
                                }
                            new carids;
                            carids = CreateVehicle(CarInfo[idx][cModel],CarInfo[idx][cLocationx],CarInfo[idx][cLocationy],CarInfo[idx][cLocationz]+1.0,CarInfo[idx][cAngle],CarInfo[idx][cColorOne],CarInfo[idx][cColorTwo],60000);
                            //ModVehicle(idx);
                            PlayerInfo[playerid][pPcarkey] = carids;
                            idx = 9999;
                            }
                            else
                            {
                            idx++;
                            }
                        }
                    return 1;
                    }
                if(PlayerInfo[playerid][pPcarkey2] == 999){
                   
                    return 1;
                    }
                if(PlayerInfo[playerid][pPcarkey3] == 999){
                   
                    return 1;
                    }
                }
            SendClientMessage(playerid, COLOR_RED, "You can not afford this vehicle right now, get more money.");
            return 1;
            }
        }
        return 1;
    }
There was no return at the end of the command
Reply
#3

Thank you, but the system doesn't spawn any cars or neither creates a file.... (vehicle file)

Where did I make a mistake ?
Reply
#4

Also you should replace:
pawn Код:
return 1;
With:
pawn Код:
return 0;
Right at the very end.
Reply
#5

But it still doesn't write the car file or spawns the car.... It say's you bought it, and that the seller gave you the key but when I want to write a file and spawn the car

can someone help me please
Reply
#6

-- BUMP --
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)