SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 01/06/2017, 09:17 PM   #21
Nero_3D
High-roller
 
Nero_3D's Avatar
 
Join Date: Jun 2007
Location: Germany
Posts: 2,850
Reputation: 675
Default Re: How to use "DestroyVehicle" whitout player in vehicle?

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
Nero_3D is online now   Reply With Quote
Old 02/06/2017, 08:46 PM   #22
JuzDoiT
Huge Clucker
 
Join Date: Feb 2015
Location: Albania
Posts: 219
Reputation: 1
Default Re: How to use "DestroyVehicle" whitout player in vehicle?

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;

__________________
JuzDoiT is offline   Reply With Quote
Old 02/06/2017, 09:59 PM   #23
tekass
Little Clucker
 
Join Date: May 2017
Posts: 21
Reputation: 0
Default Re: How to use "DestroyVehicle" whitout player in vehicle?

Ok thanks all you have good help me
tekass is offline   Reply With Quote
Old 06/06/2017, 01:58 AM   #24
tekass
Little Clucker
 
Join Date: May 2017
Posts: 21
Reputation: 0
Default Re: How to use "DestroyVehicle" whitout player in vehicle?

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!");
		}
tekass is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with "FADMIN" | How can i measure the Axis if i want to attach a object to a vehicle or player? ZayanImran Server Support 2 24/01/2013 07:38 PM
Does "DestroyVehicle" call public OnVehicleDeath? pasha97 Scripting Help 1 16/06/2012 03:20 PM
[Include] "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. iPLEOMAX Includes 46 28/01/2012 06:09 PM
"Slight homing", make a missile "Slightly!" home a vehicle. Donya Help Archive 4 11/06/2011 09:20 PM
Is player talks, use OnePlayAnim(playerid,"PED","IDLE_CHAT",4.0,0,0,0,0,0); Ihsan_Cingisiz Help Archive 5 30/05/2010 03:26 PM


All times are GMT. The time now is 06:37 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.