Nov 21, 2024, 13:24:25
Ownage Owls

Author Topic: [TUT] Water colour, custom textures  (Read 11290 times)

Jan 9, 2011, 17:09:57
Read 11290 times
Offline

MxRstyle


To change the watercolor in a map:
1# Create a .lua file using any kind of program, for example, notepad 
2# name it as client.lua
3# in your meta.xml file copy this
Code: [Select]
<script src="client.lua" type="client" /> 
    so it should be like this:
Code: [Select]
<meta>
    <script src="client.lua" type="client" />
    <info gamemodes="race" type="map" name="Your map name" author="your name" version="1.0.0" />
    <map src="yourmapname.map" dimension="0" />
    <settings>
        <setting name="#skins" value='[ &quot;random&quot; ]' />
        <setting name="#maxplayers" value="[ 32 ]" />
        <setting name="#gamespeed" value="[ 1 ]" />
        <setting name="#ghostmode" value='[ &quot;false&quot; ]' />
        <setting name="#time" value="12:0" />
        <setting name="#vehicleweapons" value='[ &quot;true&quot; ]' />
        <setting name="#minplayers" value="[ 0 ]" />
        <setting name="#weather" value="[ 0 ]" />
        <setting name="#gravity" value="[ 0.008000 ]" />
        <setting name="#waveheight" value="[ 0 ]" />
        <setting name="#respawntime" value="[ 5 ]" />
        <setting name="#locked_time" value="[ false ]" />
        <setting name="#duration" value="[ 600 ]" />
        <setting name="#respawn" value='[ &quot;none&quot; ]' />
    </settings>
</meta>
4# open the client.lua and copy this:
Code: [Select]
setWaterColor(0,0,0) -- in rgb colours5# Save it and test the map, it must work!

To change textures:
1# - 3# same as above.

4# open the client.lua and copy this:
Code: [Select]
function start ()
txd = engineLoadTXD("texturenamegoeshere.txd") -- change texturenamegoeshere for your txd file name
engineImportTXD(txd, 0000 ) -- 0000 represents the object id which you want to replace
end


addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), start )

5# run it

« Last Edit: Jan 9, 2011, 18:08:38 by Mdbelen »

Jan 9, 2011, 17:12:36
Reply #1
Offline

Millhouse

Member
Can you make colSphere that works corectly?
what script do, if you goes out of that sphere you die...

Code: [Select]
henk = createColSphere ( 2613,-4258,3000, 300 )that is position of sphere X,Y,Z and 300 is size of sphere

whole script:

Code: [Select]
function start()
henk = createColSphere ( 2613,-4258,3000, 300 )
end
addEventHandler("onClientResourceStart",getRootElement(),start )

function koeksnor ()
setElementHealth ( getLocalPlayer(), 0 )
end
addEventHandler ( "onClientColShapeLeave",getRootElement(), koeksnor )

but everytime you pickup the repair everybody die, wtf
« Last Edit: Jan 9, 2011, 17:15:46 by Millhouse »

Jan 9, 2011, 18:17:12
Reply #2
Offline

Mdbelen

Staff
guys, you can always ask me if you have any questions about scripting.

The Problem with your code, Mill, is that you attached the 'onClientColShapeLeave'-Event to the root-element, which means that it is triggered for every colshape, not only for the one you just created.

Working way should be:
Code: (lua) [Select]
function start()
local henk = createColSphere( 2613, -4258, 3000, 300 );
addEventHandler( 'onClientColShapeLeave', henk, koeksnor, false );
end;
addEventHandler( 'onClientResourceStart', getResourceRootElement(), start );

function koeksnor ()
setElementHealth(getLocalPlayer(), 0);
end;

Jan 9, 2011, 18:31:09
Reply #3
Offline

Millhouse

Member
nice mdbelen it works, tnx alot

Jan 15, 2011, 01:27:52
Reply #4
Offline

Mdbelen

Staff
Try this, works better^^
Code: [Select]
addEventHandler( 'onClientResourceStart', getResourceRootElement(),
function()
addEventHandler( 'onClientColShapeLeave', createColSphere( 2613, -4258, 3000, 300 ),
function(theElement, matchingDimension)
if (matchingDimension) and (theElement==getLocalPlayer()) then
setElementHealth(theElement, 0);
end;
end, false );
end );