Jump to content

Change CJ clothes


simstosh

Recommended Posts

On my gamemode, I gonna put a GUI system to the player "customize" their CJ player.

The GUI buttons and camera position is already finished, I only need to know how can I change the CJ clothes everytime when the specific player press the respective button (back 1, advance 1)

And with Wiki Offline, I can't search the right function (cause Offline Wiki search function obviously don't work)

Thanks so much :)

Link to comment

Well, this is getting me a little busy.

Tell me if this is wrong...

An table go, from 0 to the maximum items u put, right?

Ex.: from [0] to [67] (68 items on a table)

I do a outputDebugString to show me what value is being setted by the buttons, cause the shirts aren't being setted right.

But when I press the button to back, he goes one time forward, and the rest backward. If I press forward, it's the same, but on inverse, one time backward and the rest forawrd.

Why this? My "operation" is wrong?

Table with the texture/model names.

ShirtTextures = {"player_torso", "vestblack", "vest"... 
ShirtModels = {"torso", "vest", "vest"... 
local ShirtType = 1 
  
HeadTextures = {"player_face", "hairblond", "hairred"... 
HeadModels = {"head", "head", "head"... 
local HeadType = 1 
  
PantsTextures = {"player_legs", "legsblack", "legsheart"... 
PantsModels = {"legs", "legs", "legs"... 
local PantsType = 1 
  
ShoesTextures = {"foot", "bask2semi", "cowboyboot2"... 
ShoesModels = {"feet", "bask1", "biker"... 
local ShoesType = 1 

Shirt button function example

function btnShirtBefore ( button, state ) 
    if (source == Class_ShirtBefore) then 
        if(ShirtType == 0) then 
            outputDebugString ( ShirtType.." Shirt ID" ) 
            ShirtType = 0 
            addPedClothes ( localPlayer, ShirtTextures[shirtType], ShirtModels[shirtType], 0 ) 
        else 
            outputDebugString ( ShirtType.." Shirt ID" ) 
            ShirtType = ShirtType-1 
            addPedClothes ( localPlayer, ShirtTextures[shirtType], ShirtModels[shirtType], 0 ) 
        end 
    end 
end 
addEventHandler ( "onClientGUIClick", Class_ShirtBefore, btnShirtBefore, false ) 
  
function btnShirtAfter ( button, state ) 
    if (source == Class_ShirtAfter) then 
        if(ShirtType == 67) then 
            outputDebugString ( ShirtType.." Shirt ID" ) 
            ShirtType = 67 
            addPedClothes ( localPlayer, ShirtTextures[shirtType], ShirtModels[shirtType], 0 ) 
        else 
            outputDebugString ( ShirtType.." Shirt ID" ) 
            ShirtType = ShirtType+1 
            addPedClothes ( localPlayer, ShirtTextures[shirtType], ShirtModels[shirtType], 0 ) 
        end 
    end 
end 
addEventHandler ( "onClientGUIClick", Class_ShirtAfter, btnShirtAfter, false ) 

But he skips some pieces, and, like i've said, or he goes one backward and the rest forward, or one forward, and the rest backward. This is already making me sick. :P

(If you want, I upload the lua file. The file contains only the GUI and the buttons code)

EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT

Woops, my mistake.

The "numbers" problem it's my fault, I put the debug output before he does the "operation", so he output the wrong numbers.

But the pieces aren't set right. I put the "underclothes" first, and he gets the "clothes first" (underclothes it's 0/1/2/3), but he starts with the right clothes, but when you press forward, he gets the underclothes, not the right clothes, and after this, not happens again. Why?

EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT

Sorry, Sorry, Sorry, i've fixed. The error is an additional "vest" that I put on the ShirtModels Table :P

(Ok, when I do this, I was talking with a girl in MSN, so, understandable right? :P)

I have one more question...

I put a field on the skin selection screen to the player put their fictional Name / Surname... But how can I put them to work?

(The name is setted on sqlite db by a lua server script related to the character client script.)

I try this (on the principal script / gamemode file)

function onPlayerLogged ( player ) 
... 
    local account = getPlayerAccount ( player ) 
    local getpname = getAccountData ( account, "zmrp.name" ) 
    local getsurname = getAccountData ( account, "zmrp.surname" ) 
... 
    if ( account ) then 
        setPlayerNametagText ( player, getpname.."_"..getsurname ) 
... 
end 

Theorically, this should work, but isn't working. The problem isn't the function, because the same function is applying the clothes, money and other stats to the player.

Any help? :)

Link to comment

I've already debugged. He won't return any errors (no errors on MTA Server and /debugscript 3 on game). He only maintains the player's nick the same.

And player is the player ID, he isn't the problem, cause the same "player" value works to the other functions (return player account, set cj clothes, player money, etc.)

Here is the entire function.

function onPlayerLogged ( player ) 
    local getname = getPlayerName ( player ) 
    local account = getPlayerAccount ( player ) 
    local getmoney = getAccountData ( account, "zmrp.money" ) 
    local getzkills = getAccountData ( account, "zmrp.zkills" ) 
    local getzbitten = getAccountData ( account, "zmrp.zbitten" ) 
    local getmoney = getAccountData ( account, "zmrp.money" ) 
     
    local getpname = getAccountData ( account, "zmrp.name" ) 
    local getsurname = getAccountData ( account, "zmrp.surname" ) 
     
    local shirt = getAccountData ( account, "zmrp.shirt" ) 
    local head = getAccountData ( account, "zmrp.head" ) 
    local pants = getAccountData ( account, "zmrp.pants" ) 
    local shoes = getAccountData ( account, "zmrp.shoes" ) 
    if ( account ) then 
        --outputChatBox ( getteam, player, 255, 255, 0 ) -- Output they got the details wrong. 
         
        givePlayerMoney ( player, getmoney ) 
        setElementData ( player, "Zumbis mortos", getzkills ) 
        setElementData ( player, "Vezes mordido", getzbitten ) 
         
        setPlayerNametagText ( player, getpname.."_"..getsurname ) 
         
        setElementModel ( player, 0 ) 
        addPedClothes ( player, ShirtTextures[shirt], ShirtModels[shirt], 0 ) 
        addPedClothes ( player, HeadTextures[head], HeadModels[head], 1 ) 
        addPedClothes ( player, PantsTextures[pants], PantsModels[pants], 2 ) 
        addPedClothes ( player, ShoesTextures[shoes], ShoesModels[shoes], 3 ) 
         
        triggerEvent ("spawnincivilan", getRootElement(), player) 
    end 
    respawnPlayer(player) 
    fadeCamera ( player, true, 3 ) 
     
    setCameraTarget ( player, player ) 
    triggerClientEvent ( player, "showHudLoggedIn", getRootElement() ) 
end 
addEvent( "onPlayerLogged", true ) 
addEventHandler ( "onPlayerLogged", getRootElement(), onPlayerLogged ) 

Link to comment

He debugs, but won't return any errors (and show the right values)

I put this, like on Wiki

local setname = getpname.." "..getsurname 
outputDebugString( "Nome = '"..setname.."'" ) 
if (setPlayerNametagText ( player, setname )) then 
        outputDebugString( "Nick alterado! De '"..getname.."' para '"..setname.."'" ) 
end 

And the server returns this

[13:13:55] INFO: Nome = 'Maneiro Broder' 
[13:13:55] INFO: Nick alterado! De '[FOTL]SimS' para 'Maneiro Broder' 

But the nick in-game isn't changed.

I don't understand, because I've tried to create a local variable with getPlayerFromName, and using the name of the player to get the ID, but doesn't works.

By the debug, u see that the setPlayerNametagText is running (cause the use of if), but the function aren't changing his name. And the fictional name I put space, underline, all together, tried to put only setPlayerNametagText ( player, "WhateverNick" ), tried to put only the getpname, and nothing works. This function isn't working anymore or it's just with me?

Link to comment

Why don't u say this before u say me to debug the command? :(

And now I found the real command (setPlayerName) on Wiki.

I've searched for setPlayerName (a little obviously that's the function to change the name) but his name on wiki is SetPlayerName, not setPlayerName, and when I use the search, I haven't see the right command.

Anyway, thanks.

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