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

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.
Reply
#2

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
Reply
#3

try this code

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

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.
Reply
#5

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;
}
Reply
#6

Yeah that's the right one.
Reply
#7

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
Reply
#8

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>
Reply
#9

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?
Reply
#10

Change forward sscanf to other name
Reply
#11

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

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 
Reply
#13

Ok i try thanks you
Reply
#14

No it's always the same :/

thanks anyway.
Reply
#15

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!");
    } 
Reply
#16

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? ^^'
Reply
#17

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
Reply
#18

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.
Reply
#19

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
Reply
#20

#include <sscanf2>
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)