Jump to content

Can someone help me?;D


Victor214

Recommended Posts

Well, I'm trying to make a Ped Panel, to practice my Scripting Skills, But i got a problem here. Can someone help me?

When i press the button Create Ped on the GUI, Nothing happens, here is the error message :

scaled.php?server=837&filename=helpje.png&res=medium

Server-Side

 function spawnPed (source) 
  
local x,y,z = getElementPosition (source) 
pedio = createPed (0, x-2, y+2, z) 
  
end 
  
addEvent("spawnPed", true) 
addEventHandler("spawnPed", getRootElement(),spawnPed) 
  

Client-Side

 PedWdw = guiCreateWindow(255,130,582,361,"Ped Panel v1.0",false) 
CrePed = guiCreateButton(21,36,148,57,"Create Ped",false,PedWdw) 
DesPed = guiCreateButton(394,36,148,57,"Destoy Ped",false,PedWdw) 
SkinPed = guiCreateButton(208,36,148,57,"Edit Skin",false,PedWdw) 
Teleport = guiCreateButton(20,140,148,57,"Teleport to you",false,PedWdw) 
EditWpn = guiCreateButton(209,140,148,57,"Edit Weapon",false,PedWdw) 
Target = guiCreateButton(395,140,148,57,"Set Target",false,PedWdw) 
  
guiSetFont(Credit,"sa-gothic") 
  
guiSetVisible (PedWdw, false) 
  
function Scripting () 
  
    triggerServerEvent("spawnPed", getLocalPlayer()) 
  
  
end 
  
addEventHandler("onClientGUIClick", CrePed, Scripting) 
  
bindKey("F2","down", 
function () 
     guiSetVisible(PedWdw, not guiGetVisible(PedWdw)) 
     showCursor(guiGetVisible(PedWdw)) 
end) 
  
  

Link to comment

I guess your problem is in the server-side part, I don't usually work with the source variable in events, but....

  
 function spawnPed () -- No "source" in the function parameters here 
  
local x,y,z = getElementPosition (source) 
pedio = createPed (0, x-2, y+2, z) 
  
end 
  
addEvent("spawnPed", true) 
addEventHandler("spawnPed", getRootElement(),spawnPed) 
  
  
  

Link to comment
I guess your problem is in the server-side part, I don't usually work with the source variable in events, but....
  
 function spawnPed () -- No "source" in the function parameters here 
  
local x,y,z = getElementPosition (source) 
pedio = createPed (0, x-2, y+2, z) 
  
end 
  
addEvent("spawnPed", true) 
addEventHandler("spawnPed", getRootElement(),spawnPed) 
  
  
  

i tried this :(

It didn't work, But thank you for the help ;)

Link to comment

Aww. Another thing you can try then is change both scripts:

Client-side

  
function Scripting () 
  
    triggerServerEvent("spawnPed", getLocalPlayer(),getLocalPlayer()) 
end 
  

Server-side

  
 function spawnPed (player) 
  
local x,y,z = getElementPosition (player) 
pedio = createPed (0, x-2, y+2, z) 
  
end 
  
addEvent("spawnPed", true) 
addEventHandler("spawnPed", getRootElement(),spawnPed) 
  
  

Link to comment

Victor214,Your code is litle wrong .

NeXTreme's code is correct and should work idk Victor214 how you tested it.

You not need use variable source in argument function because event called source and you replace source with nil.

https://wiki.multitheftauto.com/wiki/Event

Client

  
--... 
function Scripting ( ) 
    triggerServerEvent("spawnPed", localPlayer ) -- localPlayer is source 
end 
--... 
  

Server

function spawnPed ( ) 
    local x,y,z = getElementPosition ( source ) -- source is player 
    pedio = createPed ( 0, x-2, y+2, z ) 
end 
addEvent( "spawnPed", true ) 
addEventHandler( "spawnPed", root,spawnPed ) 

P.S Use /debugscript 3 in next time.

Link to comment
Victor214,Your code is litle wrong .

NeXTreme's code is correct and should work idk Victor214 how you tested it.

You not need use variable source in argument function because event called source and you replace source with nil.

https://wiki.multitheftauto.com/wiki/Event

Client

  
--... 
function Scripting ( ) 
    triggerServerEvent("spawnPed", localPlayer ) -- localPlayer is source 
end 
--... 
  

Server

function spawnPed ( ) 
    local x,y,z = getElementPosition ( source ) -- source is player 
    pedio = createPed ( 0, x-2, y+2, z ) 
end 
addEvent( "spawnPed", true ) 
addEventHandler( "spawnPed", root,spawnPed ) 

P.S Use /debugscript 3 in next time.

I used o.O

And i even posted a SS o.O

Link to comment

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...