Jump to content

help whit colshape


Recommended Posts

Posted

I want to make that when someone enter a colshape a gui opens.

Meta:

Client:

addEventHandler ( "onResourceStart", getRootElement(), CreateGui )

function CreateGui ( theElement, matchingDimension )

local x = 0.375

local y = 0.375

local width = 0.25

local height = 0.25

local twindow = guiCreateWindow ( x, y, width, height, "Trucker Job", true )

x = 0.400

y = 0.400

width = 0.05

height = 0.05

guiCreateLabel ( x, y, width, height, "In trucker job you need to deliver some stuff to the gas stations.", true, twindow )

x = 0.100

y = 0.150

width = 0.02

height = 0.02

local conb = guiCreateButton ( x, y, width, height, "Confirm", true, twindow )

x = 0.400

local canb = guiCreateButton ( x, y, width, height, "Cancel", true, twindow )

guiSetVisible( twindow, false )

end

addEventHandler ( "onClientClick", conb, Confirm )

addEventHandler ( "onClientClick", canb, Cancel )

function Cancel ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement )

guiSetVisible( twindow, false )

showCursor ( false )

end

addEventHandler( "onClientColShapeHit", tc, check )

function check ()

guiSetVisible( twindow, true )

showCursor ( true )

end

Server:

function tped ()

local ped = createPed ( 133, 165.5587, -27.8196, 1.5781 )

local attached = createBlipAttachedTo ( ped, 60 )

local tc = createColTube ( 165.5587, -27.8196, 1.5781, 10, 5)

setElementFrozen ( ped, true )

setBlipVisibleDistance ( attached, 800 )

end

addEventHandler ( "onResourceStart", getRootElement(), tped )

function Confirm ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement )

local tt = createTeam ( "Trucker", 255, 255, 0 )

setElementModel ( thePlayer, 133 )

setPlayerTeam ( thePlayer, "Trucker" )

end

Posted

try this

Client:

  
addEventHandler ( "onResourceStart", getRootElement(), CreateGui ) 
function CreateGui ( theElement, matchingDimension ) 
local x = 0.375 
local y = 0.375 
local width = 0.25 
local height = 0.25 
local twindow = guiCreateWindow ( x, y, width, height, "Trucker Job", true ) 
  
x = 0.400 
y = 0.400 
width = 0.05 
height = 0.05 
guiCreateLabel ( x, y, width, height, "In trucker job you need to deliver some stuff to the gas stations.", true, twindow ) 
  
x = 0.100 
y = 0.150 
width = 0.02 
height = 0.02 
local conb = guiCreateButton ( x, y, width, height, "Confirm", true, twindow ) 
x = 0.400 
local canb = guiCreateButton ( x, y, width, height, "Cancel", true, twindow ) 
  
guiSetVisible( twindow, false ) 
end 
addEventHandler ( "onClientClick", conb, Confirm ) 
addEventHandler ( "onClientClick", canb, Cancel ) 
  
function Cancel ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
guiSetVisible( twindow, false ) 
showCursor ( false ) 
end 
  
addEventHandler( "onClientColShapeHit", tc, check ) 
function check (hitElement) 
if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
if not guiGetVisible(twindow) then 
guiSetVisible( twindow, true ) 
showCursor ( true ) 
end 
end 
end 
  

Posted

That script will never work, reasons:

1: You are using the event: "onResourceStart" on a client side script, should be: "onClientResourceStart".

2: You are adding the event handlers BEFORE you create the functions.

Posted

It doesnt work .-. I am a new scripter and I want to learn please Help me this is the code:

Server:  
function tped () 
        local ped = createPed ( 133, 165.5587, -27.8196, 1.5781 ) 
        local attached = createBlipAttachedTo ( ped, 60 ) 
        setElementFrozen ( ped, true ) 
        setBlipVisibleDistance ( attached, 800 )        
end 
addEventHandler ("onResourceStart", getResourceRootElement ( getThisResource () ), tped) 
  
function Confirm ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
        local tt = createTeam ( "Trucker", 255, 255, 0 ) 
        setElementModel ( thePlayer, 133 ) 
        setPlayerTeam ( thePlayer, "Trucker" ) 
end 
  
Client: 
function CreateGui ( theElement, matchingDimension ) 
        local x = 0.375 
        local y = 0.375 
        local width = 0.25 
        local height = 0.25 
        local twindow = guiCreateWindow ( x, y, width, height, "Trucker Job", true ) 
  
        x = 0.400 
        y = 0.400 
        width = 0.05 
        height = 0.05 
        guiCreateLabel ( x, y, width, height, "In trucker job you need to deliver some stuff to the gas stations.", true, twindow ) 
  
        x = 0.100 
        y = 0.150 
        width = 0.02 
        height = 0.02 
        local conb = guiCreateButton ( x, y, width, height, "Confirm", true, twindow ) 
        x = 0.400 
        local canb = guiCreateButton ( x, y, width, height, "Cancel", true, twindow ) 
  
        guiSetVisible( twindow, false ) 
end 
addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), CreateGui) 
  
addEventHandler ( "onClientClick", conb, Confirm ) 
addEventHandler ( "onClientClick", canb, Cancel ) 
  
function Cancel ( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) 
         guiSetVisible( twindow, false ) 
         showCursor ( false ) 
end 
   
function nigga () 
local tc = createColTube ( 165.5587, -27.8196, 1.5781, 10, 5) 
end 
addEventHandler ("onClientResourceStart", getResourceRootElement ( getThisResource () ), nigga) 
  
function check (hitElement) 
if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
if not guiGetVisible(twindow) then 
guiSetVisible( twindow, true ) 
showCursor ( true ) 
end 
end 
end 
addEventHandler( "onClientColShapeHit", tc, check ) 

Posted

You still haven't done what Castillo pointed out for you.

Your code has many errors and functions which don't make sense at all. For example: You're using onResourceStart (which is server-side) in client-side script, using onClientClick instead of onClientGUIClick etc. Show us that you actually made all of this by fixing some of said things so we could help you.

Posted

But what other error i have? how I know what errors are? Im new in scripting, this is my first script and I want to make that a ped whit a colshape so that when you enter the col a gui is created so you can accept the job or not. (sorry for bad english)

Posted

You can see your error using the debug ( wright 'debugscript 3' in the console ) .

+ They have allready told you your mistakes !

Posted

Exactly, because you're using SERVER side functions/events in CLIENT side. Re-read the wiki to find a difference between those two.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...