SA-MP Forums Archive
[Solved] AddVehicleComponent problem or something - 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: [Solved] AddVehicleComponent problem or something (/showthread.php?tid=108451)



[Solved] AddVehicleComponent problem or something - [Bm]rap45 - 14.11.2009

Well i work on these AddVehicleComponent thingy and all i got this

Код:
	new vehicle;
	if (strcmp("/nitro", cmdtext, true, 10) == 0)
	{
		AddVehicleComponent(vehicle,1010);
		SendClientMessage(playerid,0xFF9900AA,"Your Car Has Nitro Now");
		return 1;
	}
so when player type /nitro his car gets nitro but when i tested it just says "your car has nitro now" and the nitro doesnt appear=/
another thing if theres a tutorial for like "You need to be in a car to use this command!" to check if player is in vehicle (i know the CheckIfPlayerOnVehicle or something like that) but to know how to put it all together thanks.



Re: AddVehicleComponent problem or something - Joe Staff - 14.11.2009

'vehicle' has to be defined for it to work, you just made a variable and used it (default at 0). There's really no need for a variable anyway sense you can just use a function to retrieve a player's vehicle ID.

Try this:
pawn Код:
if (strcmp("/nitro", cmdtext, true, 10) == 0)
    {
        if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,0xFF0000FF,"You must be in a vehicle!"); //If the function 'IsPlayerInAnyVehicle' returns 0(false) then it will stop the command and send a message at the same time.
        AddVehicleComponent(GetPlayerVehicleID(playerid),1010); // no need for 'vehicle'
        SendClientMessage(playerid,0xFF9900AA,"Your Car Has Nitro Now");
        return 1;
    }



Re: AddVehicleComponent problem or something - [Bm]rap45 - 14.11.2009

Ok i get it know. thanks to you. thanks alot!