I need to make second function on this code, but got an error. Help please! -
Riwerry - 04.11.2013
Hello guys, how i can make second fucntion of command? The first function is so it attach object to vehicle, but i want to do when player type it again and on car is already this item it will destroy it, while I tried to make it i got this.
Errors:
C:\Users\Jakub\Desktop\Server\gamemodes\LVRP.pwn(3 65) : error 029: invalid expression, assumed zero
C:\Users\Jakub\Desktop\Server\gamemodes\LVRP.pwn(3 71) : warning 225: unreachable code
C:\Users\Jakub\Desktop\Server\gamemodes\LVRP.pwn(3 71) : warning 217: loose indentation
pawn Код:
Variable:
new VehicleObject[1];
COMMAND:majak(playerid, cmdtext[])
{
{
VehicleObject[0] = CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(VehicleObject[0], 541, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000000);
}
else //365 line
{
DestroyObject(VehicleObject[0]);
}
return 1;
return 1; //371 line
}
THANKS.
Respuesta: I need to make second function on this code, but got an error. Help please! -
adri1 - 04.11.2013
Where is if?
pawn Код:
COMMAND:majak(playerid, cmdtext[])
{
{
if(VehicleObject[1])
{
EDIT:
pawn Код:
COMMAND:majak(playerid, cmdtext[])
{
if(IsValidObject(VehicleObject[0]))
{
VehicleObject[0] = CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(VehicleObject[0], 541, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000000);
}
else //365 line
{
DestroyObject(VehicleObject[0]);
}
return 1;
}
Re: I need to make second function on this code, but got an error. Help please! -
Riwerry - 04.11.2013
Got an next error when i added if
C:\Users\Jakub\Desktop\Server\gamemodes\LVRP.pwn(3 62) : error 032: array index out of bounds (variable "VehicleObject")
C:\Users\Jakub\Desktop\Server\gamemodes\LVRP.pwn(3 66) : error 029: invalid expression, assumed zero
C:\Users\Jakub\Desktop\Server\gamemodes\LVRP.pwn(3 72) : warning 225: unreachable code
C:\Users\Jakub\Desktop\Server\gamemodes\LVRP.pwn(3 72) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
pawn Код:
COMMAND:majak(playerid, cmdtext[])
{
{
if(VehicleObject[1]) //362 line
VehicleObject[0] = CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(VehicleObject[0], 541, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000000);
}
else //366 line
{
DestroyObject(VehicleObject[0]);
}
return 1;
return 1; //372 line
//EDIT: Eh, okay mate i copied your edited post now works thx
Respuesta: I need to make second function on this code, but got an error. Help please! -
adri1 - 04.11.2013
See edit.
Re: I need to make second function on this code, but got an error. Help please! -
Riwerry - 04.11.2013
Ehm, mate compiled tried but here is the problem

When i type command it keep still removing object. It not place it first..
Re: I need to make second function on this code, but got an error. Help please! -
bensmart469 - 04.11.2013
Change this:
if(IsValidObject(VehicleObject[0]))
to
if(!IsValidObject(VehicleObject[0]))
Right now, you're doing a check to see if the object is valid, and if it is, you end up creating it again.
Re: I need to make second function on this code, but got an error. Help please! -
Riwerry - 04.11.2013
Well still not working, mate pls if u can edit this all code to work correctly thanks.
pawn Код:
COMMAND:majak(playerid, cmdtext[])
{
if(!IsValidObject(VehicleObject[0]))
{
VehicleObject[0] = CreateObject(18646,0,0,-1000,0,0,0,100);
AttachObjectToVehicle(VehicleObject[0], 541, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000000);
}
else
{
DestroyObject(VehicleObject[0]);
}
return 1;
}
Re: I need to make second function on this code, but got an error. Help please! -
bensmart469 - 04.11.2013
AttachObjectToVehicle(VehicleObject[0], 541, 0.449999,0.674999,0.375000,0.000000,0.000000,0.000 000);
You do realise this will attach to vehicle ID 541, not model?
Re: I need to make second function on this code, but got an error. Help please! -
Riwerry - 04.11.2013
I just put id of Bullet becouse actually for testing attaching. But in future i want to make so only Static Bullet can be used to attach object, becouse it will be police Bullet. What do you advise? What should i do with it? I'm beginner. Can you post the full code how i can make it? Thanks mate alot
Re: I need to make second function on this code, but got an error. Help please! -
Riwerry - 04.11.2013
Fixed now, thanks Ben for now i edited this vehicle ID to GetPlayerVehicleID(playerid), but now I want to know how to make it, so it will be possible add this object only to one static vehicle, what I will choose, any ideas? thanks