Jump to content

Skin selector


Gothem

Recommended Posts

well im like make a skin selector but im have a problem....

here is the code

function seleccion(player) 
    spawnPlayer(player, -2026.5035, 156.7506, 29.0391, 269.1424, 0) 
    fadeCamera(player,true) 
    if ( getCameraMode ( player ) == "player" ) then 
        setCameraMode ( player, "fixed" ) 
    else 
        setCameraMode ( player, "player" ) 
        setCameraMode ( player, "fixed" )   --Not bullshit. Fo real. 
    end 
    setCameraPosition(player, -2010.5035, 156.7506, 29.0391) 
    setTimer( setCameraLookAt, 500, 10, player, -2026.5035, 156.7506, 29.0391) 
    bindKey(player,"enter","down",Aparecer,player) 
    bindKey(player,"arrow_l","down",Cambiar,player) 
    bindKey(player,"arrow_r","down",Cambiar,player) 
end 
  
function Cambiar( player, key ) 
    local skin 
    skin = getPlayerSkin(player) 
    if(key == "arrow_l" and skin ~= 0) then 
        setPlayerSkin(player,skin - 1) 
    else  
        setPlayerSkin(player,skin + 1) 
    end 
    setCameraPosition(player, -2010.5035, 156.7506, 29.0391) 
    setCameraLookAt( player, -2026.5035, 156.7506, 29.0391) 
end 
  
function Aparecer( player ) 
    unbindKey ( player, "enter", "down", Aparecer ) 
    unbindKey ( player, "arrow_l", "down", Cambiar ) 
    unbindKey ( player, "arrow_r", "down", Cambiar ) 
    setCameraMode ( player, "player" ) 
end 

this are the functions to be called you need put

seleccion(source) 

in the player join :)

well the problem is.. it dont change skin :(

Edited by Guest
Link to comment

Do you have any event handlers or calls on that function?

You'd probably want to add this line in, then.

addEventHandler ( "onPlayerJoin", getRootElement(), seleccion ) 

Also, the OnPlayerJoin has no parameters, so you'd want to replace all the 'player' with source, where you're referring to the player.

Read over this page for an example on how you should structure it.

Link to comment
i would also like to point out there is some skins that wont work properly might even crash i ain't testeds

From my own tests that I've conducted, I've concluded that using a skin ID that isn't an accepted MTA skin will not crash the server. This isn't SAMP after all :P.

EDIT: Doesn't seem like it crashes the client, either, if that's what you're wondering.

Edited by Guest
Link to comment
Do you have any event handlers or calls on that function?

You'd probably want to add this line in, then.

addEventHandler ( "onPlayerJoin", getRootElement(), seleccion ) 

Also, the OnPlayerJoin has no parameters, so you'd want to replace all the 'player' with source, where you're referring to the player.

Read over this page for an example on how you should structure it.

yeah i put a handler :)

(never too idiot :lol: )

well im think the problem is the skins :)

but i dont know how make the code for jump the crasher skins :|

Link to comment

Camera functions are not working well. Some people say it works for them w/o any problems but some people say (inc. me) that they've got some issues.

I've never managed to make them work, even using more timers.

What do you see if you said you can't see yourself? My camera is somewhere in the middle of SA and it's facing East. Also, the camera's position is (I assume from what I see) 0, 0, 0.

Link to comment
Camera functions are not working well. Some people say it works for them w/o any problems but some people say (inc. me) that they've got some issues.

I've never managed to make them work, even using more timers.

What do you see if you said you can't see yourself? My camera is somewhere in the middle of SA and it's facing East. Also, the camera's position is (I assume from what I see) 0, 0, 0.

yeah that is true but i have see it work when the resource start when the player is already connected no for connecting players :shock:

Link to comment

I think you need to make another onPlayerJoin and a timer

  
  
function playerJoin () 
       setTimer ( seleccion, 2000, 1, source ) 
end 
  
addEventHandler ( "onPlayerJoin", getRootElement(), playerJoin ) 
  

Like this i think

Link to comment

I've had similar issues with the camera not being properly set for a newly joined player. The camera would just get stuck at 0, 0, 0 like you already mentioned. It has to do with the fact that a player is not fully spawned (or at least in my experience it is). The problem occurs only and only when a player joins for the fist time. I solved it by setting a timer (runs only once when a player joins the server) that loops for n times for the duration of n seconds positioning the camera in each tick event (10 recursions with an interval of 1000ms did the job for me). After that the camera works fine.

Link to comment
function Inicio( res ) 
    players = getElementsByType ( "player") 
    for k,v in ipairs(players) do --Game start spawn 
        outputChatBox("Bienvenido a Nuestro Servidor",v) 
        spawnPlayer(v, -2026.5035, 156.7506, 29.0391, 269.1424, 0) 
        setTimer(seleccion,3000,2,v) 
        fadeCamera ( v, true ) 
    end 
end 
  
function Muerte( ammo, attacker, weapon, bodypart ) 
    setTimer ( seleccion, 3000, 1, source ) 
end 
  
function Conexion() 
    outputChatBox("Bienvenido a Nuestro Servidor ",source) 
    spawnPlayer(source, -2026.5035, 156.7506, 29.0391, 269.1424, 0) 
    setTimer ( seleccion, 1000, 2, source ) 
    fadeCamera ( source, true ) 
end 
  
function seleccion(player) 
    spawnPlayer(player, -2026.5035, 156.7506, 29.0391, 269.1424, 0) 
    setCameraMode ( player,"fixed") 
    setTimer(setCameraPosition, 500, 2, player, -2010.5035, 156.7506, 29.0391) 
    setTimer( setCameraLookAt, 550, 10, player, -2026.5035, 156.7506, 29.0391) 
    bindKey(player,"enter","down",Aparecer) 
    bindKey(player,"arrow_l","down",Cambiar) 
    bindKey(player,"arrow_r","down",Cambiar) 
end 
  
function Cambiar( player, key ) 
    local skin 
    skin = getPlayerSkin(player) 
    if(key == "arrow_l" and skin ~= 0) then 
        setPlayerSkin(player,skin - 1) 
    else  
        setPlayerSkin(player,skin + 1) 
    end 
    setCameraLookAt( player, -2026.5035, 156.7506, 29.0391) 
end 
  
function Aparecer( player ) 
    unbindKey ( player, "enter", "down", Aparecer ) 
    unbindKey ( player, "arrow_l", "down", Cambiar ) 
    unbindKey ( player, "arrow_r", "down", Cambiar ) 
    setCameraMode ( player, "player" ) 
end 
  
addEventHandler("onPlayerWasted", getRootElement(),Muerte) 
addEventHandler("onResourceStart", getRootElement(),Inicio) 
addEventHandler("onPlayerJoin", getRootElement(),Conexion) 

here is the entire code :)

it dont work now :(

Link to comment

You may spawn, but camera may not go there where you want. Try with a command and see if camera goes there.

NOTE: If you have camera mode set to fixed and you will set it again to fixed it will be changed to "player" but getCameraMode is returns "fixed", that's a bug I think.

Link to comment

I've seen a possible solution posted by someone in the bugs forum a while ago. It seems that you can not set the camera position and make it look at something in the same frame. The solution posted (not sure if it is working) toggled to fixed/player mode and set a timer to either set the camera or make it look at a target after a short timeout.

Link to comment
I've seen a possible solution posted by someone in the bugs forum a while ago. It seems that you can not set the camera position and make it look at something in the same frame. The solution posted (not sure if it is working) toggled to fixed/player mode and set a timer to either set the camera or make it look at a target after a short timeout.

Yeah you won't be able to do all your camera calls in sequence and do need timers. You might also need that change to player mode first before trying fixed. You end up with stuff like:

  
setCameraMode(player,"player") 
setCameraMode(player,"fixed") 
setTimer(setCameraLookAt,100,1,player,....) 
setTimer(setCameraPosition,200,1,player,...) 
  

The order of LookAt/Position can also make a difference - the above is what I've had most success with.

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