This topic was marked solved by its starter, on November 19th, 03:22 PM

SonmezAltug

  • Newbie
  • Posts: 7
Code with a secret bug
«  »
Code: [Select]
else if( cmd == "detonate" )
{
local veh = FindVehicle( 16 );
else if( veh )
{
local Pos = player.Pos, checkpoly = InPoly( Pos.x, Pos.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786);
if( checkpoly == true )
{
veh.Kill();
player.Cash += 10000;
SaveAccount(player)
}
}
}

Hi guys, i need a help for a mission script. I want to make a suicide mission, a bad guy gets truck with bombs comes to airport gate and he type "detonate" and make his truck explode. 16 is cargo truck's ID. I have a problem, scripts works very well. I am typing "detonate" and if i am in poly of airport gate i am leave the truck and in a far location i type the code and let it explode but after that if i type this code i can still earn money. If i type 10 times i get 100.000$ but why ? I don't understand i don't have a car but i can earn money again ? There's something to fix it but i can't find it. If someone joins inpoly he can use this bug billions of times and he can get millions of money. Code still works if you don't have vehicle 16 and he still gives you money ? I am waiting for your support.

Xhefri

  • Newbie
  • Posts: 34
Re: Code with a secret bug
« Reply #1,  »
I would probably say check if the player is in a vehicle or not and if he isnt then he wont receive the money neither the car will explode.
Code: [Select]
if ( !player.Vehicle )

AroliS^

  • Jr. Member
  • Learning of Mike Tyson K.O
  • Posts: 51
Re: Code with a secret bug
« Reply #2,  »Last edited
You my little turtle, remember this:

Code: [Select]
local veh = FindVehicle( 16 )
// is looking for the vehicle even if the instance is not on the car
Code: [Select]
instead use local veh = player.Vehicle
// now yes, my little turtle now it is checking if the instance is on the car

Athanatos

  • Hero Member
  • Romania Cops N Robbers Lead Developer
  • Posts: 817
Re: Code with a secret bug
« Reply #3,  »
You better try storing the mission vehicle's id in a global variable:
Code: [Select]
MISSION_CAR <- CreateVehicle(...).ID;

SonmezAltug

  • Newbie
  • Posts: 7
Re: Code with a secret bug
« Reply #4,  »
Quote from AroliS^ on November 14th, 05:25 PM
You my little turtle, remember this:

Code: [Select]
local veh = FindVehicle( 16 )
// is looking for the vehicle even if the instance is not on the car
Code: [Select]
instead use local veh = player.Vehicle
// now yes, my little turtle now it is checking if the instance is on the car
Thanks master Splinter! But i can come with a different car and can make it explode. I want only 16 (cargo truck).
Quote from Athanatos on November 14th, 06:40 PM
You better try storing the mission vehicle's id in a global variable:
Code: [Select]
MISSION_CAR <- CreateVehicle(...).ID;
How can i use global variable? I'm new and I don't know it. If i add player.Vehicle to first, yes code works if player has a car but then that car is maybe every car. I want only  vehicle 16 exlode. Can you help me with this.

umar4911

  • Sr. Member
  • Creating own server!
  • Posts: 475
Re: Code with a secret bug
« Reply #5,  »
Firstly, you cannot use else if immediately after the cmd one in the manner you did.
Secondly, You're getting money because of the InPoly. The vehicle when destroyed, it respawns. As soon as it respawns, the first validation is checked as true. Next, if the PLAYER is standing in the poly, it is also marked true. Since it's a suicidal mission and player is blasted too, try this piece of code:
Code: [Select]
else if( cmd == "detonate" )
{
local veh = FindVehicle( 16 );
if( veh )
{
local Pos = player.Pos, checkpoly = InPoly( Pos.x, Pos.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786);
if( checkpoly == true && player.Vehicle.ID == veh.ID)
{
veh.Kill();
player.Cash += 10000;
SaveAccount(player);
}
}
}

I am gamer, programmer and hacker. Try to find me!
xD

SonmezAltug

  • Newbie
  • Posts: 7
Re: Code with a secret bug
« Reply #6,  »
Quote from umar4911 on November 15th, 06:17 AM
Firstly, you cannot use else if immediately after the cmd one in the manner you did.
Secondly, You're getting money because of the InPoly. The vehicle when destroyed, it respawns. As soon as it respawns, the first validation is checked as true. Next, if the PLAYER is standing in the poly, it is also marked true. Since it's a suicidal mission and player is blasted too, try this piece of code:
Code: [Select]
else if( cmd == "detonate" )
{
local veh = FindVehicle( 16 );
if( veh )
{
local Pos = player.Pos, checkpoly = InPoly( Pos.x, Pos.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786);
if( checkpoly == true && player.Vehicle.ID == veh.ID)
{
veh.Kill();
player.Cash += 10000;
SaveAccount(player);
}
}
}
I added your script now it gives this error AN ERROR HAS OCCURED [the index 'ID' does not exist]

AroliS^

  • Jr. Member
  • Learning of Mike Tyson K.O
  • Posts: 51
Re: Code with a secret bug
« Reply #7,  »Last edited
Quote from SonmezAltug on November 15th, 01:46 PM
Quote from umar4911 on November 15th, 06:17 AM
Firstly, you cannot use else if immediately after the cmd one in the manner you did.
Secondly, You're getting money because of the InPoly. The vehicle when destroyed, it respawns. As soon as it respawns, the first validation is checked as true. Next, if the PLAYER is standing in the poly, it is also marked true. Since it's a suicidal mission and player is blasted too, try this piece of code:
Code: [Select]
else if( cmd == "detonate" )
{
local veh = FindVehicle( 16 );
if( veh )
{
local Pos = player.Pos, checkpoly = InPoly( Pos.x, Pos.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786);
if( checkpoly == true && player.Vehicle.ID == veh.ID)
{
veh.Kill();
player.Cash += 10000;
SaveAccount(player);
}
}
}
I added your script now it gives this error AN ERROR HAS OCCURED [the index 'ID' does not exist]
Oh my litte turtle, I did not get what you were trying to say but now I got it, here you go

so, if you do not want to be in the car, then you do not have to compare the player pos, you better compare the vehicle pos.

Code: [Select]
else if ( cmd == "detonate" )
{
local veh = FindVehicle( 16 );
if( ( veh ) && ( !player.Vehicle ) )
{
    local pos = veh.Pos, poly = InPoly( pos.x, pos.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786 );
if( poly )
{
veh.Kill();
player.Cash += 10000;
SaveAccount( player );
}
else MessagePlayer( "Not available.", player );
}
else MessagePlayer( "You can't be inside a car.", player );
}


SonmezAltug

  • Newbie
  • Posts: 7
Re: Code with a secret bug
« Reply #8,  »
Quote from AroliS^ on November 15th, 05:27 PM
Quote from SonmezAltug on November 15th, 01:46 PM
Quote from umar4911 on November 15th, 06:17 AM
Firstly, you cannot use else if immediately after the cmd one in the manner you did.
Secondly, You're getting money because of the InPoly. The vehicle when destroyed, it respawns. As soon as it respawns, the first validation is checked as true. Next, if the PLAYER is standing in the poly, it is also marked true. Since it's a suicidal mission and player is blasted too, try this piece of code:
Code: [Select]
else if( cmd == "detonate" )
{
local veh = FindVehicle( 16 );
if( veh )
{
local Pos = player.Pos, checkpoly = InPoly( Pos.x, Pos.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786);
if( checkpoly == true && player.Vehicle.ID == veh.ID)
{
veh.Kill();
player.Cash += 10000;
SaveAccount(player);
}
}
}
I added your script now it gives this error AN ERROR HAS OCCURED [the index 'ID' does not exist]
Oh my litte turtle, I did not get what you were trying to say but now I got it, here you go

so, if you do not want to be in the car, then you do not have to compare the player pos, you better compare the vehicle pos.

Code: [Select]
else if ( cmd == "detonate" )
{
local veh = FindVehicle( 16 );
if( ( veh ) && ( !player.Vehicle ) )
{
    local pos = veh.Pos, poly = InPoly( pos.x, pos.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786 );
if( poly == true )
{
veh.Kill();
player.Cash += 10000;
SaveAccount( player );
}
else MessagePlayer( "Not available.", player );
}
else MessagePlayer( "You can't be inside a car.", player );
}

Sir, I just want vehicle 16 explode with "detonate" code in the inpoly of airport gate, inpoly works well but i have a problem for detecting vehicle ID. Script can't read the ID, i want script reads you are in the vehicle ID 16 goood then wait i am checking your inpoly ah perfect you are inpoly then booom. But there's a problem in the checking the car ID. If i am inpoly without car and if i type that code it still gives money. I want him if i haven't got vehicle 16 then script should return false and it need to say me "Get vehicle 16 then come". Sorry for my amateur English.

Maximiliano

  • Newbie
  • Posts: 20

DraGone

  • Newbie
  • Posts: 3
Re: Code with a secret bug
« Reply #10,  »Last edited
I assume you want the command to work when
- The player is in the vehicle ID 16
- The player is at airport gate (i assume the InPoly works), i havent tested it..
Code: [Select]
else if ( cmd == "detonate" )
{
// just change the vehicle ID here if needed
local targetVehID = 16;

local targetVeh = FindVehicle( targetVehID );

// check whether the vehicle exist
if ( targetVeh )
{
// check whether player is in a vehicle and his vehicle ID is correct
if ( player.Vehicle && player.Vehicle.ID == targetVehID )
{
// check whether the player's vehicle is within the area of airport gate ?
if ( InPoly( targetVeh.Pos.x, targetVeh.Pos.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786 ) )
{
targetVeh.Kill( );
player.Cash += 10000;
SaveAccount( player );
}
else MessagePlayer( "You need to drive to airport gate", player );
}
else MessagePlayer( "You need to enter vehicle ID "+ targetVehID, player );
}
else MessagePlayer( "Vehicle ID "+ targetVehID +" is not found", player );
}

But, i would suggest you to create the vehicle and store the vehicle's ID in a global variable instead (as in Athanatos's post). The vehicle ID would not be the same if you somehow created even one new vehicle before this vehicle. In that case, this vehicle ID wont be 16 and the command wont work as you want it.

Athanatos

  • Hero Member
  • Romania Cops N Robbers Lead Developer
  • Posts: 817
Re: Code with a secret bug
« Reply #11,  »Last edited
To create a global variable use:
Code: [Select]
VARIABLE_NAME <- VALUE;
To use a global variable simply use
Code: [Select]
VARIABLE_NAME = 2; //Sets the value to 2.

To make sure a global variable is avalable anywhere, define it in onScriptLoad() or outside any function.

In your case, you will need to store a vehicle id inside a global variable. This is an example on how to do so.

Code: [Select]
GVAR_MISSION_CAR <- CreateVehicle(...).ID;

function DestroyMissionCar()
{
   if(GVAR_MISSION_CAR == -1) return;
   FindVehicle(GVAR_MISSION_CAR).Kill();
   //some more stuff...
   GVAR_MISSION_CAR = -1;
}


Saiyan Attack

  • Jr. Member
  • [KoF]Killer
  • Posts: 70
Re: Code with a secret bug
« Reply #12,  »Last edited
Quote from SonmezAltug on November 15th, 08:00 PM
Quote from AroliS^ on November 15th, 05:27 PM
Quote from SonmezAltug on November 15th, 01:46 PM
Quote from umar4911 on November 15th, 06:17 AM
Firstly, you cannot use else if immediately after the cmd one in the manner you did.
Secondly, You're getting money because of the InPoly. The vehicle when destroyed, it respawns. As soon as it respawns, the first validation is checked as true. Next, if the PLAYER is standing in the poly, it is also marked true. Since it's a suicidal mission and player is blasted too, try this piece of code:
Code: [Select]
else if( cmd == "detonate" )
{
local veh = FindVehicle( 16 );
if( veh )
{
local Pos = player.Pos, checkpoly = InPoly( Pos.x, Pos.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786);
if( checkpoly == true && player.Vehicle.ID == veh.ID)
{
veh.Kill();
player.Cash += 10000;
SaveAccount(player);
}
}
}
I added your script now it gives this error AN ERROR HAS OCCURED [the index 'ID' does not exist]
Oh my litte turtle, I did not get what you were trying to say but now I got it, here you go

so, if you do not want to be in the car, then you do not have to compare the player pos, you better compare the vehicle pos.

Code: [Select]
else if ( cmd == "detonate" )
{
local veh = FindVehicle( 16 );
if( ( veh ) && ( !player.Vehicle ) )
{
    local pos = veh.Pos, poly = InPoly( pos.x, pos.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786 );
if( poly == true )
{
veh.Kill();
player.Cash += 10000;
SaveAccount( player );
}
else MessagePlayer( "Not available.", player );
}
else MessagePlayer( "You can't be inside a car.", player );
}

Sir, I just want vehicle 16 explode with "detonate" code in the inpoly of airport gate, inpoly works well but i have a problem for detecting vehicle ID. Script can't read the ID, i want script reads you are in the vehicle ID 16 goood then wait i am checking your inpoly ah perfect you are inpoly then booom. But there's a problem in the checking the car ID. If i am inpoly without car and if i type that code it still gives money. I want him if i haven't got vehicle 16 then script should return false and it need to say me "Get vehicle 16 then come". Sorry for my amateur English.
i still don't get what you want from this code and the code describe itself as player want to commit suicide to get some money ! its like you want to create terrorism attack in the airport main gate !! or something and i don't know which vehicle you are using to destroy but here is the code that will detect vehicle/ID and if it suit it will make blast along with the person who is inside the vehicle! or i suggest you to create separate vehicle for it as describe by @Athanatos

// Destroyed with vehicle/model
Code: [Select]
else if( cmd == "detonate" ) {
local veh = player.Vehicle;
if( veh && veh.Model == 191 ) { // vehicle is PCJ BIKE
local axis = veh.Pos, checkpoly = InPoly( axis.x, axis.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786);
if( checkpoly == true ) {
veh.Kill();
player.Cash += 10000;
SaveAccount(player);
}
else MessagePlayer("out of range!",player);
}
else MessagePlayer("You must inside in a recommanded vehicle!",player);
}

// destroyed with vehicle/ID
Code: [Select]
else if( cmd == "detonate" ) {
local veh = player.Vehicle;
if( veh && veh.ID == 16 ) {
local axis = veh.Pos, checkpoly = InPoly( axis.x, axis.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786);
if( checkpoly == true ) {
veh.Kill();
player.Cash += 10000;
SaveAccount(player);
}
else MessagePlayer("out of range!",player);
}
else MessagePlayer("You must inside in a recommanded vehicle!",player);
}
Code: [Select]
// to clarify that the vehicle you pickup is vehicle/id 16? or not!
else if(cmd == "get16") {
local veh = FindVehicle( 16 );
if( veh ) return player.PutInVehicleSlot(veh,0);
}

SonmezAltug

  • Newbie
  • Posts: 7
Re: Code with a secret bug
« Reply #13,  »
Quote from DraGone on November 16th, 04:44 AM
I assume you want the command to work when
- The player is in the vehicle ID 16
- The player is at airport gate (i assume the InPoly works), i havent tested it..
Code: [Select]
else if ( cmd == "detonate" )
{
// just change the vehicle ID here if needed
local targetVehID = 16;

local targetVeh = FindVehicle( targetVehID );

// check whether the vehicle exist
if ( targetVeh )
{
// check whether player is in a vehicle and his vehicle ID is correct
if ( player.Vehicle && player.Vehicle.ID == targetVehID )
{
// check whether the player's vehicle is within the area of airport gate ?
if ( InPoly( targetVeh.Pos.x, targetVeh.Pos.y, -1399, -772,  -1401, -848, -1473, -849,  -1486, -786 ) )
{
targetVeh.Kill( );
player.Cash += 10000;
SaveAccount( player );
}
else MessagePlayer( "You need to drive to airport gate", player );
}
else MessagePlayer( "You need to enter vehicle ID "+ targetVehID, player );
}
else MessagePlayer( "Vehicle ID "+ targetVehID +" is not found", player );
}

But, i would suggest you to create the vehicle and store the vehicle's ID in a global variable instead (as in Athanatos's post). The vehicle ID would not be the same if you somehow created even one new vehicle before this vehicle. In that case, this vehicle ID wont be 16 and the command wont work as you want it.
Thanks man yours is best, this is working properly.