Sign in to follow this  
Zadara

Some Questions

Recommended Posts

Well, i have some issues with scripting, here there are:

Question 1:How can i attach something when its spawn, not respawn, just spawn when the gamemode start. There is a onVehicleRespawn, but not a onVehicleSpawn... That says wiki...

Question 2: When i attach a little rc vehicle to a normal plane, and i make a sharp bend with the normal airplane, the rc vehicle

just let loose. It's not attach anymore on the plane. Is this a bug or something? And is there a way to reslove this?

Question 3: Is there away to change the weapon model? Like that your holding a M4 with a AK47 skin?

Thanks,

Share this post


Link to post

Answer:

1: For as far as I know onVehicleRespawn works on spawn too. Try it?

2: Known issue. (Issue #3962)

3: You can't switch the model of any existing GTA SA object/weapon/skin. However, in the nightlies you can replace the textures of them. So like giving skins a lil' reskin, or a weapon or whatever. You need to wait for 1.0 though, or take a nightly. (although I disrecommend it due to extremely low (active) playercount)

Share this post


Link to post
Answer:

1: For as far as I know onVehicleRespawn works on spawn too. Try it?

2: Known issue. (Issue #3962)

3: You can't switch the model of any existing GTA SA object/weapon/skin. However, in the nightlies you can replace the textures of them. So like giving skins a lil' reskin, or a weapon or whatever. You need to wait for 1.0 though, or take a nightly. (although I disrecommend it due to extremely low (active) playercount)

1. I will give it a try...

2. Strange, by the bomb drop script of someone (forgot the name, my bad) the bomb not falling of...

3. I have already a nighlty, can't i place the rocketlauncher model in the download map so the client download it, en then replace it. Its gat to be possible, because you also can replace normal models... :?

Share this post


Link to post

3. I have already a nighlty, can't i place the rocketlauncher model in the download map so the client download it, en then replace it. Its gat to be possible, because you also can replace normal models... :?

You can replace normal models but you can't replace characters nor weapons.

Share this post


Link to post

Ok, new question, there is a problem with my script,

The console say that bindkey is a bad agrument.

function OnRustlerSpawn ( exploded ) 
    if ( getVehicleID ( source ) == 476 ) then 
        outputChatBox ("The Ruslter is respawnd.") 
        local x, y, z = getElementPosition( source ) 
        local rcbaron = createVehicle ( 464, x, y, z + -1.2  ) 
        attachElementToElement( rcbaron, source, 0, 0, -1.2 ) 
    end 
end 
addEventHandler ( "onVehicleRespawn", getRootElement(), OnRustlerSpawn ) 
  
function enterRustler ( player, seat, jacked ) 
    if ( getVehicleID ( source ) == 476 ) then 
        bindKey ( player, "lshift", "down", On, element ) 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), enterRustler ) 
  
function OnPlayerPressShift(key, keyState) 
    if (key == "lshift") then 
        detachElementFromElement ( rcbaron, source ) 
        outputChatBox( "Bomb launchd!" ) 
    else 
        outputChatBox( "Element is not attached" ) 
    end 
end 

Share this post


Link to post
bindKey ( player, "lshift", "down", On, element ) 

What is On and element? Check the bindKey documentation. You can answer all these questions by yourself.

Share this post


Link to post

1. No, OnVehicleRespawn only works when the vehicle hasbeen exploded, not when the recourses starts. :( Is there away to make this?

3. I fix it... Stupid of me, that i can't fix it by my self.

Share this post


Link to post
1. No, OnVehicleRespawn only works when the vehicle hasbeen exploded, not when the recourses starts. :( Is there away to make this?

3. I fix it... Stupid of me, that i can't fix it by my self.

1. I don't understand anything... You don't want to use onResourceStart because you want to use onVehicleRespawn which doesn't work when resource start but you want something that works when resource start? What is your problem?

3. Don't understand this neither... "You fix it but can't fix it yourself"? Hmm... :roll:

Share this post


Link to post

1. When you create the vehicle in the script, create the element to attach then attach it...

  
    vehicle = createVehicle(.....) 
  
    object = createObject(......) 
      
    --In DP2.3 use 
    attachElementToElement(object, vehicle, x, y, z, rx, ry, rz)  
  
    --or in the nightlies use 
    attachElements(object, vehicle, x, y, z, rx, ry, rz) 
  
  

Share this post


Link to post
1. No, OnVehicleRespawn only works when the vehicle hasbeen exploded, not when the recourses starts. :( Is there away to make this?

3. I fix it... Stupid of me, that i can't fix it by my self.

1. I don't understand anything... You don't want to use onResourceStart because you want to use onVehicleRespawn which doesn't work when resource start but you want something that works when resource start? What is your problem?

3. Don't understand this neither... "You fix it but can't fix it yourself"? Hmm... :roll:

1. I wanna attach a element to the vehicle, when its spawn, if i use OnVehicleRespwan it only get attachd, when i exploding the vehicle, and then Respawn. But i wanna that the element get immediately attachd when the vehicle get for the first time get spawn. I can't use OnResourcesStart because some reason, I'll save the reason of you.

:wink: 3. You dont have to understand me... I have fix it already. :P (My english is not real good)

NEW: I have a problem, when the rcbaron is attachd and i fly up, the other vehicle get of the rcbaron, because of a bug in MTA. But when i fly a minute in the sky, the rcbaron, get attachd again. The strange thing is, that i use the event OnVehicleRespawn, OnVehicleEnter, ect... so that a new rcbaron only get attachd when is use Onvehiclerespawn... ect..

Why the rcbaron get attachd again?

To [DKR]silverfang: I tought that there need to be a event to use the AttachElementtoElemnt/AttachElements function... I will give it a try.

Share this post


Link to post

If the vehicles are created on resource start:

function doSomethingWithTheVehiclesOrWhatever() 
    for index,vehicle in ipairs(getElementsByType("vehicle")) do -- This do the following with ALL vehicles on the server... 
        outputChatBox(getVehicleName(vehicle)) -- Output the vehicle's name 
    end 
end 
addEventHandler("onResourceStart",getResourceRootElement(),doSomethingWithTheVehiclesOrWhatever) 

A little spammish, but hey, it's just an example. :)

Share this post


Link to post
If the vehicles are created on resource start:
function doSomethingWithTheVehiclesOrWhatever() 
    for index,vehicle in ipairs(getElementsByType("vehicle")) do -- This do the following with ALL vehicles on the server... 
        outputChatBox(getVehicleName(vehicle)) -- Output the vehicle's name 
    end 
end 
addEventHandler("onResourceStart",getResourceRootElement(),doSomethingWithTheVehiclesOrWhatever) 

A little spammish, but hey, it's just an example. :)

I can't really use this because i wanna attach element also when its respawn after a explosion. :wink:

Share this post


Link to post

Then add a second event handler to the function too.. I can't see a problem

Share this post


Link to post
Then add a second event handler to the function too.. I can't see a problem

Like this?

addEventHandler ( "onVehicleRespawn", getResourceRootElement(), doSomethingWithTheVehiclesOrWhatever ) 

Share this post


Link to post
function doSomethingWithTheVehiclesOrWhatever() 
    for index,vehicle in ipairs(getElementsByType("vehicle")) do 
         outputVehicleName(vehicle) 
    end 
end 
addEventHandler("onResourceStart",getResourceRootElement(),doSomethingWithTheVehiclesOrWhatever) 
  
function outputVehicleName(vehicle) 
    outputChatBox(getVehicleName(vehicle)) 
end 
addEventHandler("onVehicleRespawn",getRootElement(),function() outputVehicleName(source) end) 

Something like this should work.

Share this post


Link to post
function doSomethingWithTheVehiclesOrWhatever() 
    for index,vehicle in ipairs(getElementsByType("vehicle")) do 
         outputVehicleName(vehicle) 
    end 
end 
addEventHandler("onResourceStart",getResourceRootElement(),doSomethingWithTheVehiclesOrWhatever) 
  
function outputVehicleName(vehicle) 
    outputChatBox(getVehicleName(vehicle)) 
end 
addEventHandler("onVehicleRespawn",getRootElement(),function() outputVehicleName(source) end) 

Something like this should work.

Ok thanks! (Are you Dutch?(Ik ook 8) )

Only this problem:

I can't make a unbindkey... well here is the function, the console says the unbindKey is a bad argument... :?

function exitRustler1 ( thePlayer, seat, jacked ) 
    unbindKey ( player, "r", "down", funcInput ) 
end 
addEventHandler ( "onVehicleExit", rustler1, exitRustler1 ) 

Share this post


Link to post
your function uses thePlayer, not player

Ok thanks. :wink:

Antoher bug... :lol::P

The console says that isVehicleOnGround is a bad argument..

function OnBombHitGround(loss) 
    if ( isVehicleOnGround( ruslter1 )  == false ) then 
        local pX, pY, pZ = getElementPosition ( rcbaron ) 
        createExplosion ( pX, pY, pZ, 6 ) 
        blowVehicle ( rcbaron ) 
    end 
end 

Share this post


Link to post

you do understand what bad argument means right?

do you really need us to tell you what is wrong?

it means that there is something wrong with the argument your are passing to the function, in this case isVehicleOnGround.

now, i would suggest that you have spelt it incorrectly (ruslter1 instead of rustler1) but i can't be sure of that.

what you could do, however, is debug your scripts before you come here to have someone explain what hte error message means.

Share this post


Link to post
you do understand what bad argument means right?

do you really need us to tell you what is wrong?

it means that there is something wrong with the argument your are passing to the function, in this case isVehicleOnGround.

now, i would suggest that you have spelt it incorrectly (ruslter1 instead of rustler1) but i can't be sure of that.

what you could do, however, is debug your scripts before you come here to have someone explain what hte error message means.

A already fix that, but it still says that IsVehicleOnGround is a bad argument, i will give you the complete script, i have change it, so its 1.0 compatible.

local rustler1 = createVehicle ( 476, -696.59759521484, 897.68084716797, 13.838381767273, 2.5280456542969, 358.68106079102, 176.86285400391 ) 
local x, y, z = getElementPosition( rustler1 ) 
local rcbaron = createVehicle ( 464, x, y, z + -1.2  ) 
  
function OnRuslter1Spawn( res ) 
    attachElements( rcbaron, rustler1, 0, 0, -1.2 ) 
end 
addEventHandler ( "onResourceStart", getRootElement(), OnRuslter1Spawn ) 
  
function OnRustler1ReSpawn ( exploded ) 
    outputChatBox ("The Ruslter is respawnd.") 
    attachElements( rcbaron, rustler1, 0, 0, -1.2 ) 
end 
addEventHandler ( "onVehicleRespawn", rustler1, OnRustler1ReSpawn ) 
  
function enterRustler1 ( player, seat, jacked ) 
    bindKey ( player, "r", "down", funcInput ) 
end 
addEventHandler ( "onVehicleEnter", rustler1, enterRustler1 ) 
  
function exitRustler1 ( thePlayer, seat, jacked ) 
    unbindKey ( thePlayer, "r", "down", funcInput ) 
end 
addEventHandler ( "onVehicleExit", rustler1, exitRustler1 ) 
  
function funcInput ( player, key, keyState ) 
    if (key == "r") and ( isElementAttached ( rcbaron ) == true ) then 
        detachElements ( rcbaron, rustler1 ) 
        outputChatBox( "Bomb launchd!" ) 
            if ( isVehicleOnGround( rcbaron )  == true ) then 
                local pX, pY, pZ = getElementPosition ( rcbaron ) 
                createExplosion ( pX, pY, pZ, 6 ) 
                blowVehicle ( rcbaron ) 
    else 
        outputChatBox( "You already launchd the bomb!" ) 
    end 
end 
  

Share this post


Link to post

Correct me if I'm wrong, but that script won't even run as far as I can see...

... 
function funcInput ( player, key, keyState ) 
    if (key == "r") and ( isElementAttached ( rcbaron ) == true ) then 
        detachElements ( rcbaron, rustler1 ) 
        outputChatBox( "Bomb launchd!" ) 
            if ( isVehicleOnGround( rcbaron )  == true ) then 
                local pX, pY, pZ = getElementPosition ( rcbaron ) 
                createExplosion ( pX, pY, pZ, 6 ) 
                blowVehicle ( rcbaron ) 
-- Maybe an end here would be useful, to close "if ( isVehicleOnGround...) then" 
    else 
        outputChatBox( "You already launchd the bomb!" ) 
    end 
end 

Don't forget to use "restart [resource]" (or "refresh") after you made changes to a resource. It prevents bugs like these.

Share this post


Link to post
Correct me if I'm wrong, but that script won't even run as far as I can see...
... 
function funcInput ( player, key, keyState ) 
    if (key == "r") and ( isElementAttached ( rcbaron ) == true ) then 
        detachElements ( rcbaron, rustler1 ) 
        outputChatBox( "Bomb launchd!" ) 
            if ( isVehicleOnGround( rcbaron )  == true ) then 
                local pX, pY, pZ = getElementPosition ( rcbaron ) 
                createExplosion ( pX, pY, pZ, 6 ) 
                blowVehicle ( rcbaron ) 
-- Maybe an end here would be useful, to close "if ( isVehicleOnGround...) then" 
    else 
        outputChatBox( "You already launchd the bomb!" ) 
    end 
end 

Don't forget to use "restart [resource]" (or "refresh") after you made changes to a resource. It prevents bugs like these.

I did'nt test it... But i need to fix isVehicleOnGround. You see, i wanna create a explosion on the place where the rcbaron is hitting the ground. Like a bomb drop script I already create a other verison of my script, that i know thats works. But only that IsVehicleOnGround does'nt work. The console says the thats IsVehicleOnGround is a bad agrument. Forget everything else, i just wanna fix the IsVehicleOnGround problem.

Share this post


Link to post

The script won't run anyway if you don't have correct syntax. So there is no point testing it.

isVehicleOnGround needs a vehicle element argument. So you have to check what are you giving the function..

Put outputChatBox(getElementType(rcbaron)) before "if isVehicleOnGround" thingie and fix syntax problems. Then test it and tell us what you get.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.