CMD:veh with a 3D Textdraw
#1

so what i am trying is that when an admin spawn a admin car through /acar and they pick a car and color, it should attach a 3Dtextdraw to that car saying "ADMIN SPAWNED CAR". I've done this so far, but it still does not work...

Код:
CMD:acar(playerid, params[]) {
	if(PlayerInfo[playerid][pAdmin] >= 3) {

		new
			iVehicle,
			iColors[2],
			Text3D:vehicle3Dtext[MAX_VEHICLES];

		if(sscanf(params, "iii", iVehicle, iColors[0], iColors[1])) {
			SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /veh [model ID] [color 1] [color 2]");
		}
		else if(!(400 <= iVehicle <= 611)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid model specified (model IDs start at 400, and end at 611).");
		}
		else if(IsATrain(iVehicle)) {
			SendClientMessageEx(playerid, COLOR_GREY, "Trains cannot be spawned during runtime.");
		}
		else if(!(0 <= iColors[0] <= 255 && 0 <= iColors[1] <= 255)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid color specified (IDs start at 0, and end at 255).");
		}
		else for(new iIterator; iIterator < sizeof(CreatedCars); iIterator++) if(iIterator >= 49) {
			return SendClientMessageEx(playerid, COLOR_GRAD1, "The maximum limit of 50 spawned vehicles has been reached.");
		}
		else if(CreatedCars[iIterator] == INVALID_VEHICLE_ID) {

			new
				Float: fVehPos[4];

			new fVW = GetPlayerVirtualWorld(playerid);
			GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]);
			GetPlayerFacingAngle(playerid, fVehPos[3]);
			CreatedCars[iIterator] = CreateVehicle(iVehicle, fVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1);
		    vehicle3Dtext[CreatedCars] = Create3DTextLabel( "ADMIN SPAWNED CAR", 0xFF0000AA, 0.0, 0.0, 0.0, 50.0, 0, 1 );
			Attach3DTextLabelToVehicle( vehicle3Dtext[ CreatedCars ] , CreatedCars, 0.0, 0.0, 2.0);
			VehicleFuel[CreatedCars[iIterator]] = 100.0;
			Vehicle_ResetData(CreatedCars[iIterator]);
			LinkVehicleToInterior(CreatedCars[iIterator], GetPlayerInterior(playerid));
			SetVehicleVirtualWorld(CreatedCars[iIterator], fVW);
			return SendClientMessageEx(playerid, COLOR_GREY, "Vehicle spawned!");
		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
	return 1;
}
Reply
#2

the way I'd do it is :
PHP код:
CreatedCars[MAX_PLAYERS][50];
vehicle3Dtext[MAX_PLAYERS][50];
CreatedCars[playerid][iIterator] = CreateVehicle(iVehiclefVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1);
vehicle3Dtext[playerid][iIterator] = Create3DTextLabel"ADMIN SPAWNED CAR"0xFF0000AA0.00.00.050.00);
Attach3DTextLabelToVehiclevehicle3Dtext[playerid][iIterator] , CreatedCars0.00.02.0); 
Try to pull out my idea from that, not trying to play puzzle but I have no idea what vars you are using. Just use a double array so you have each player can have 50 cars to spawn,
Reply
#3

Still don't manage to figure it out, do you need anymore information?
Reply
#4

Add this below sa-mp include : native IsValidVehicle(vehicleid);
- Every admin can spawn 50 cars. If you want that all admins can only spawn 50 cars change the code by removing playerid;
variables :
CreatedCars[MAX_PLAYERS][50];
vehicle3Dtext[MAX_PLAYERS][50];

Код:
CMD:acar(playerid, params[]) {
	if(PlayerInfo[playerid][pAdmin] >= 3) {
		new
			iVehicle,
			iColors[2],
			Text3D:vehicle3Dtext[MAX_VEHICLES];

		if(sscanf(params, "iii", iVehicle, iColors[0], iColors[1])) {
			SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /veh [model ID] [color 1] [color 2]");
		}
		else if(!(400 <= iVehicle <= 611)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid model specified (model IDs start at 400, and end at 611).");
		}
		else if(IsATrain(iVehicle)) {
			SendClientMessageEx(playerid, COLOR_GREY, "Trains cannot be spawned during runtime.");
		}
		else if(!(0 <= iColors[0] <= 255 && 0 <= iColors[1] <= 255)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid color specified (IDs start at 0, and end at 255).");
		}
		else {
			new Float: fVehPos[4];
                        for(new i; i<50;i++)
                        {
                             if(IsValidVehicle(CreatedCars[playerid][i]) continue; 
                              new fVW = GetPlayerVirtualWorld(playerid);
			GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]);
			GetPlayerFacingAngle(playerid, fVehPos[3]);
			CreatedCars[playerid][i] = CreateVehicle(iVehicle, fVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1);
		        vehicle3Dtext[playerid][i] = Create3DTextLabel( "ADMIN SPAWNED CAR", 0xFF0000AA, 0.0, 0.0, 0.0, 50.0, 0, 1 );
			Attach3DTextLabelToVehicle(vehicle3Dtext[playerid][i],CreatedCars[playerid][i], 0.0, 0.0, 2.0);
			VehicleFuel[CreatedCars[playerid][i]] = 100.0;
			Vehicle_ResetData(CreatedCars[playerid][i]);
			LinkVehicleToInterior(CreatedCars[playerid][i], GetPlayerInterior(playerid));
			SetVehicleVirtualWorld(CreatedCars[iIterator], fVW);
                        SendClientMessageEx(playerid, COLOR_GREY, "Vehicle spawned!");
                        break;
                        }
		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
	return 1;
}
Reply
#5

Getting these errors, i did exacly as you said.

PHP код:
./gamemodes/PGRP.pwn(21015) : error 001expected token"-identifier-"but found "if"
./gamemodes/PGRP.pwn(21016) : warning 217loose indentation
./gamemodes/PGRP.pwn(21012) : warning 204symbol is assigned a value that is never used"iColors"
./gamemodes/PGRP.pwn(21011) : warning 203symbol is never used"iVehicle"
./gamemodes/PGRP.pwn(21011 -- 21018) : error 017undefined symbol "iVehicle"
./gamemodes/PGRP.pwn(21021) : error 017undefined symbol "iVehicle"
./gamemodes/PGRP.pwn(21024) : error 017undefined symbol "iColors"
./gamemodes/PGRP.pwn(21024) : error 029invalid expressionassumed zero
./gamemodes/PGRP.pwn(21024) : warning 217loose indentation
./gamemodes/PGRP.pwn(21024) : warning 215expression has no effect
./gamemodes/PGRP.pwn(21024) : error 001expected token";"but found "]"
./gamemodes/PGRP.pwn(21024) : fatal error 107too many error messages on one line 
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)