simstosh Posted October 9, 2010 Share Posted October 9, 2010 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
dzek (varez) Posted October 9, 2010 Share Posted October 9, 2010 http://www.google.com/search?hl=pl&safe ... =&gs_rfai= (click small link "copy" near every result) and function wiki page: http://webcache.googleusercontent.com/s ... ient=opera Link to comment
simstosh Posted October 9, 2010 Author Share Posted October 9, 2010 Thanks, I will try. And as always, very helpful varez (And with the right names, I found on Offline Wiki ) Link to comment
simstosh Posted October 9, 2010 Author Share Posted October 9, 2010 One more question... Can I create a Array to put all textures/models names? I think it's more easy to do... Example: Just do HeadModels = {"a","b","c"}, and after this use only HeadModels[0], HeadModels[1], HeadModels[2]... ? Link to comment
Callum Posted October 9, 2010 Share Posted October 9, 2010 Yes, but they're not referred to as arrays, they're called tables. Try reading this. Link to comment
simstosh Posted October 9, 2010 Author Share Posted October 9, 2010 Yeah, i saw on lua wiki before post this (because I saw about the numbers using [#] method, not about text) And on php this method is called array, not table Too much language codes on my head haha Thanks for the help. Link to comment
simstosh Posted October 10, 2010 Author Share Posted October 10, 2010 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. (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 (Ok, when I do this, I was talking with a girl in MSN, so, understandable right? ) 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
50p Posted October 11, 2010 Share Posted October 11, 2010 - Do you get warning/error messages? - What is player? - Debug your script before you ask questions, please. Link to comment
simstosh Posted October 11, 2010 Author Share Posted October 11, 2010 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
dzek (varez) Posted October 11, 2010 Share Posted October 11, 2010 i just want to add that debugging is not only to show debug window. read about debugging once again Link to comment
simstosh Posted October 11, 2010 Author Share Posted October 11, 2010 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
dzek (varez) Posted October 11, 2010 Share Posted October 11, 2010 you know what is nametag? is that thing hovering in SA words above players head (with healthbar) nickname is different thing! Link to comment
simstosh Posted October 11, 2010 Author Share Posted October 11, 2010 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now