SA-MP Forums Archive
How to use "DestroyVehicle" whitout player in vehicle? - 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)
+--- Thread: How to use "DestroyVehicle" whitout player in vehicle? (/showthread.php?tid=635057)

Pages: 1 2


How to use "DestroyVehicle" whitout player in vehicle? - tekass - 31.05.2017

Hi all, i need help with the Callback "DestoyVehicle" Because I have succeded to make it work but only with GetPlayerVehicleID but I need to use it without player in the vehicle for my crusher system.

Here is the method I use:


Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext,"/fb", true))
     	{
      	new Float:x, Float:y, Float:z;
	new idcar;
	idcar = GetVehiclePos(idcar, x, y, z);
	DestroyVehicle(idcar);
     	GameTextForPlayer(playerid, "Vehicule broyer!", 3500, 1);
        }
}
Tanks for you help.


Re: How to use "DestroyVehicle" whitout player in vehicle? - JasonRiggs - 31.05.2017

Make it for example /fb <carid> add after the opened bracket if(strcmp, "u", carid) or smth, show me the create car cmd to re send u the code with fix


Re: How to use "DestroyVehicle" whitout player in vehicle? - skuller12 - 31.05.2017

try this code

Код:
new idcar = GetPlayerVehicleID(playerid);
	DestroyVehicle(idcar);
     	GameTextForPlayer(playerid, "Vehicule broyer!", 3500, 1);



Re: How to use "DestroyVehicle" whitout player in vehicle? - JasonRiggs - 31.05.2017

Quote:
Originally Posted by skuller12
Посмотреть сообщение
try this code

Код:
new idcar = GetPlayerVehicleID(playerid);
	DestroyVehicle(idcar);
     	GameTextForPlayer(playerid, "Vehicule broyer!", 3500, 1);
Maybe you didnt understand him, he wants to destroy a car while player is NOT inside it.


Re: How to use "DestroyVehicle" whitout player in vehicle? - skuller12 - 31.05.2017

Top:

native IsValidVehicle(vehicleid);

After in ZCMD:

Код:
CMD:fb(playerid, params[])
{
new v;
if(sscanf(params, "i", v)) return SendClientMessage(playerid, -1, "/fb <car id>");
if(!IsValidVehicle(v)) return 1;
DestroyVehicle(v);
 return 1;
}



Re: How to use "DestroyVehicle" whitout player in vehicle? - JasonRiggs - 31.05.2017

Yeah that's the right one.


Re: How to use "DestroyVehicle" whitout player in vehicle? - JasonRiggs - 31.05.2017

That's the right one but he needs it like that
Код:
if(!strcmp(cmdtext,"/fb", true))
{
new v;
if(sscanf(params, "i", v)) return SendClientMessage(playerid, -1, "/fb <car id>");
if(!IsValidVehicle(v)) return 1;
DestroyVehicle(v);
 return 1;
}
as he isnt using ZCMD


Re: How to use "DestroyVehicle" whitout player in vehicle? - tekass - 31.05.2017

Thanks for your help, but i have again error, how i defined "sscanf" please? Is just with "new sscanf;" ?

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext,"/fb", true))
{
new v;
if(sscanf(params, "i", v)) return SendClientMessage(playerid, -1, "/fb <car id>");
if(!IsValidVehicle(v)) return 1;
DestroyVehicle(v);
return 1;
}
Код:
C:\Users\KEVIN\Desktop\My-RP-Life\filterscripts\CasseLegacy.pwn(387) : error 012: invalid function call, not a valid address
C:\Users\KEVIN\Desktop\My-RP-Life\filterscripts\CasseLegacy.pwn(387) : error 017: undefined symbol "params"
C:\Users\KEVIN\Desktop\My-RP-Life\filterscripts\CasseLegacy.pwn(387) : error 029: invalid expression, assumed zero
C:\Users\KEVIN\Desktop\My-RP-Life\filterscripts\CasseLegacy.pwn(387) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
PS: I need add that?

Код:
#include <sscanf>



Re: How to use "DestroyVehicle" whitout player in vehicle? - tekass - 31.05.2017

I try with that:

Код:
forward sscanf(const data[], const format[], {Float,_}:...);
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext,"/fb", true))
	{
	new v;
	if(sscanf(params, "i", v)) return SendClientMessage(playerid, -1, "/fb <car id>");
	if(!IsValidVehicle(v)) return 1;
	DestroyVehicle(v);
	return 1;
	}
but error is:

Код:
C:\Users\KEVIN\Desktop\My-RP-Life\filterscripts\CasseLegacy.pwn(386) : error 004: function "sscanf" is not implemented
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Which is the valid function for sscanf please?


Re: How to use "DestroyVehicle" whitout player in vehicle? - Whatname - 31.05.2017

Change forward sscanf to other name


Re: How to use "DestroyVehicle" whitout player in vehicle? - tekass - 31.05.2017

That is to say? I need to change the location of the sscanf2.inc file?


Re: How to use "DestroyVehicle" whitout player in vehicle? - Whatname - 31.05.2017

No change this :

PHP Code:

forward sscanf
(const data[], const format[], {Float,_}:...); 
To this

PHP Code:

forward s_sscanf
(const data[], const format[], {Float,_}:...); //or any other name except existing function 



Re: How to use "DestroyVehicle" whitout player in vehicle? - tekass - 31.05.2017

Ok i try thanks you


Re: How to use "DestroyVehicle" whitout player in vehicle? - tekass - 31.05.2017

No it's always the same :/

thanks anyway.


Re: How to use "DestroyVehicle" whitout player in vehicle? - Nero_3D - 31.05.2017

Without using strtok, sscanf or any other dependency
PHP Code:
//OnPlayerCommandText
    
if(strcmp(cmdtext,"/fb"true3) == && cmdtext[3] <= ' ') {
        if(
cmdtext[3] == EOS || cmdtext[4] == EOS) {
            return 
SendClientMessage(playerid, -1"/fb <car id>");
        }
        if(
DestroyVehicle(strval(cmdtext[4])) == 0) {
            return 
SendClientMessage(playerid, -1"Invalid vehicleid!");
        }
        return 
SendClientMessage(playerid, -1"Vehicle destroyed!");
    } 



Re: How to use "DestroyVehicle" whitout player in vehicle? - tekass - 31.05.2017

Hum...Thanks for your help, there are no error and your command is functional, but all commands in my script doesn't work... haha... only your commande.

You have the solution please? ^^'


Re: How to use "DestroyVehicle" whitout player in vehicle? - Nero_3D - 31.05.2017

No clue, could be anything, but adding other strcmp commands like that should work
PHP Code:
//
    
if(strcmp(cmdtext"/hello1"true) == 0) {
        return 
SendClientMessage(playerid, -1"Hello1");
    }
    if(
strcmp(cmdtext,"/fb"true3) == && cmdtext[3] <= ' ') {
        if(
cmdtext[3] == EOS || cmdtext[4] == EOS) {
            return 
SendClientMessage(playerid, -1"/fb <car id>");
        }
        if(
DestroyVehicle(strval(cmdtext[4])) == 0) {
            return 
SendClientMessage(playerid, -1"Invalid vehicleid!");
        }
        return 
SendClientMessage(playerid, -1"Vehicle destroyed!");
    }
    if(
strcmp(cmdtext"/hello2"true) == 0) {
        return 
SendClientMessage(playerid, -1"Hello2");
    } 
if /hello1 and /hello2 is working that the problem is within your code

So if your other commands are also strcmp based they should work


Re: How to use "DestroyVehicle" whitout player in vehicle? - ShihabSoft - 01.06.2017

Quote:

if(strcmp(cmdtext,"/fb", true, 3) == 0 && cmdtext[3] <= ' ') {

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.


Re: How to use "DestroyVehicle" whitout player in vehicle? - tekass - 01.06.2017

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


Re: How to use "DestroyVehicle" whitout player in vehicle? - skuller12 - 01.06.2017

#include <sscanf2>