How to use "DestroyVehicle" whitout player in vehicle?
#21

Quote:
Originally Posted by ShihabSoft
View Post
What if the command the user entered is just of 3 characters, just /fb, then the cmdtext[3] would crash, with an array index out of bounds exception. It's better to use sscanf for these purposes. NEVER TRUST USER INPUT.
Well pawn uses zero terminated strings, even if it doesn't you should know that array parameter are simple addresses without any knowledge of the size, therefore there is no out of bound check!

Quote:
Originally Posted by tekass
View Post
I put the command in another GM and it works however i am forced to put the id car for the destroy and i want for something that would allow me to detroy the vehicle at the same time as i close the crusher. If is possible

Again tanks for your help +1 for you
Just call DestroyVehicle with the correct vehicleid if the crusher closes, therefor you need to check if a vehicle is close to the crusher
Loop through all vehicles and check with GetVehicleDistanceFromPoint if they are near the crusher and delete them
Reply
#22

this is the best i think

PHP Code:
CMD:adestroycar(playeridparams[])
{
    new 
TargetID,destroyveh,str1[128];
    if(
sscanf(params"u"TargetID)) return SendClientMessage(playerid,COLOR_RED,"USAGE: /adestroycar [id]");
     if(
TargetID == INVALID_PLAYER_ID || !IsPlayerConnected(TargetID)) return SendClientMessage(playeridCOLOR_RED"That Player Is Not Connected");
    if(
GetPlayerState(TargetID) != PLAYER_STATE_DRIVER) return SendClientMessage(playeridCOLOR_RED"Player Is Not In A Vehicle.");
    else
    {
        
format(str1,sizeof(str1),"%s (%d)'s Vehicle Has Been Destroyed.",pname(TargetID),TargetID);
        
SendClientMessage(playerid,COLOR_HOTPINK,str1);
        
destroyveh GetPlayerVehicleID(TargetID);
        
DestroyVehicle(destroyveh);
    }
     return 
1;

Reply
#23

Ok thanks all you have good help me
Reply
#24

Thank you very much !!! this is the result of your help is pefectely functional !

Code:
if(strcmp(cmdtext,"/fb", true, 3) == 0 && cmdtext[3] <= ' ')
		{
		if(IsPlayerInRangeOfPoint(playerid, 15.0, 1634.8997, -1818.1466, 15.1864))
			{
			MoveObject(broyeur12, 1636.9797, -1818.1466, 15.1864, 1.5, 0.00000, 0.00000, 0.00000);
			MoveObject(broyeur13, 1637.2100, -1818.3542, 15.1864, 1.5, 0.00000, 0.00000, 0.00000);
			SetTimer("ouverture", 3000, false);
			GameTextForPlayer(playerid, "Broyeur en marche!", 3500, 3);
			GetPlayerName(playerid, sendername, sizeof(sendername));
                        new text[100];
			format(text, sizeof(text), "*%s active le broyeur а l'aide de sa tйlйcommande.", sendername);
		}
		if(cmdtext[3] == EOS || cmdtext[4] == EOS)
		{
		return SendClientMessage(playerid, -1, "/fb <car id>");
		}
		if(DestroyVehicle(strval(cmdtext[4])) == 0)
		{
		return SendClientMessage(playerid, -1, "id du vehicule invalide!");
		}
		return SendClientMessage(playerid, -1, "Vehicule detruit!");
		}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)