Jump to content

Extremo

Members
  • Posts

    37
  • Joined

  • Last visited

Everything posted by Extremo

  1. Hm, I tested your idea about triggering a server event as well, but it didn't work either. So I am having a guess here that somewhere inside the code there is an error that makes it impossible for the client to load the script at all. I'll have a look at it now and see if I can find any error - if not I'll probably get back to this thread and post some more code. The code is quite big and I don't wanna end up asking you to make it for me. EDIT: You're actually right - the problem lies in the simple fact that the client script is not yet loaded when the server is requesting the particular event. Is there some way to make sure that something is only triggered after all files have been loaded? Right - I just triggered a server event whenever the client resource was started and it now works flawlessly - not a single error. This is resolved =) Regards.
  2. Hey guys, I am literally ripping my hair out here. I've been working on this since the morning and it just keeps on giving me the same error no matter what I try. It's funny because I actually don't see anything wrong at all - so I guess another pair of eyes might be nice. The problem is that I call a client-event from my server but I keep getting the issue back that apparently this "client-event" has not been added by the client. Here's a couple lines: Server: function ShowAccountMenu() setElementFrozen(source, true) if getAccount(getPlayerName(source)) then triggerClientEvent("extremo::login::show", source) else triggerClientEvent("extremo::register::show", source) end end Client: addEvent("extremo::login::show", true, true) addEvent("extremo::register::show", true, true) addEvent("extremo::login::ok", true, true) addEvent("extremo::register::ok", true, true) addEvent("extremo::login::bad",true, true) addEvent("extremo::register::bad",true, true) addEventHandler("extremo::login::show", getRootElement(), function () guiSetVisible(accMenu, true) showCursor(true) guiSetInputEnabled(true) end ) Clearly I have added the event and I've even told the code that it can be remotely called by the server. I tried it with false on the remote part. I tried it without that parameter at all. I tried moving it around. I had an external function at first - so then I put the function into the addEventHandler. I don't know what else to do really, not even the debug shows me any errors. I am lost here.
  3. Hey, The problem is that onResourceStart does not actually have a player-parameter. It has a source parameter which however in your case would be: function showTextDisplay ( player ) -- player == getResourceRootElement(getThisResource()) Which for obvious reasons is not the player. You can figure the rest from there I am sure. Regards.
  4. Extremo

    Hide map

    Weird, for me it still displays it. Are you sure you made it all clientside? function DisableMap() toggleControl("radar", false) end addEventHandler("onClientResourceStart", getRootElement(), DisableMap) Works flawless on clientside. @ Shadow Your script enables it for everybody or disables it for everybody doesn't it? I want to disable it for everybody and renable it for specific players - not everybody. Regards.
  5. Thanks I found the problem. I left out the third arguement on SetTimer assuming that it would automatically be zero, but instead it actually didn't create the timer at all. Silly me. This is now solved. Thanks for all the help =)
  6. You only made some code to make the ped walk forwards and I've already made that - my concern lies within the function to update the rotation for every player which I posted here: Click me EDIT: Nevermind I just saw yours lol. Must of skipped that one somehow. EDIT2: Yeah I already changed the if like you have, so the problem is probably not in there. You also have the SetTimer thing execute the UpdatePeds only 5 times and I've already removed that as well. The "if" looks like this: if not (ped[p]==nil) then So the problem isn't in there. It's rather that for some weird reason, ped[p] is always nil.
  7. Thanks for figuring out that one but it didn't fix the whole thing either way. It still doesn't work so I added a debug to see if it even finds any "ped[p]" that isn't nil and it doesn't. Which leads me to the question that maybe the "ped" array is wrong? EDIT: I forgot to mention tho that I use the "ped" array already before-hand to make the ped walk forwards and that works fine. However inside the loop the ped array doesn't seem to work properly. Can you see any reason why?
  8. Because one gets the position of the player, the other however gets the position of the ped?
  9. Oh, I thought that was the time the function may have to execute. Ah I just read the wiki again and I clearly misread it. I thought it said: "TimeToExecuteFunction" Thanks again! EDIT: It doesn't seem to work even after changing the SetTimer thing.
  10. Right, I sort of fixed the issue. Apparently the issue was using "table.insert" which I used after I saw it being used by one of the above posters. Though now that it does work, another code that was connected to it still doesn't. Could someone have a look at this? I am sorry I don't mean to ask you all to code for me but I am not so familiar with this all. The solution to my first problem was just adding forward btw. The problem however why it didn't work even though I added forward was because the lua script crashed at "table.insert". After I reverted that change for obvious reasons it worked flawlessly. So I don't know if it was just me or table.insert wasn't the best solution at hand. Either way, this is my new problem: Clientside - below the makeWalk part function findRotation(x1,y1,x2,y2) local t = -math.deg(math.atan2(x2-x1,y2-y1)) if t < 0 then t = t + 360 end; return t; end function UpdatePeds() local players = getElementsByType( "player" ) for k, p in ipairs(players) do if not ped[p] == nil then local x,y,z = getElementPosition(p) local px,py,pz = getElementPosition(ped[p]) local a = findRotation(px,py,x,y) setPedRotation(ped[p], a) end end end setTimer(UpdatePeds, 500, 5) It doesn't seem to update the rotation at all. Does anyone have a clue why? Any help is appreciated. Sorry if I am bothering anyone here.
  11. Already did. It does and I also checked if any of them is nil - they aren't. In fact thePlayer is correct. Not sure if thePed arguement is passed on correctly though.
  12. I am afraid but that didn't fix the issue.
  13. Extremo

    Hide map

    I don't think you understood my question precisely. I am trying to toggle the F11 map for everybody though if I give them a map script-wise I want to re-enable the map for them, but only for those who DO have a map.
  14. I think you must use setPedAnimation. Well that would just play the animation but not move the ped.
  15. Hey, Apart from the table.insert I don't see much difference. Also, it actually doesn't save the ped's related to the player but only stores the peds related to peds which is not what I want. I want the ped to store in that array relative to the player's index. I hope you get my point. However since yours isnt really that different how'd yours make a difference? The ped is being created fine however it doesn't start moving.
  16. Extremo

    Hide map

    That's only for screen radar, doesn't affect to F11. Actually it does. The F11 map is disabled. I tried it myself.
  17. Extremo

    Hide map

    That helped greatly but one problem still persists. What if I wanted to enable it for one guy again? Not everyone but only one guy? Regards.
  18. Hey guys, It seems I've run into another problem but it isn't clear to me what exactly is wrong. So I got the following code: Serverside: function createPedForPlayer(thePlayer, command, pedModel) local x,y,z = getElementPosition(thePlayer) local ped = createPed( tonumber(pedModel), x, y, z, 0.0, true) if ped == nil then outputChatBox("Error ped was not created.", thePlayer) return end triggerClientEvent("OnPedWalk", getRootElement(), thePlayer, ped) end addCommandHandler("createPed", createPedForPlayer) Clientside: local ped = {} function makeWalk(thePlayer, thePed) ped[thePlayer] = thePed setPedControlState(thePed, "walk", true) end addEvent("OnPedWalk", true) addEventHandler("OnPedWalk", getRootElement(), makeWalk) I don't see what exactly may be wrong here? Could someone point me into the right direction? That would be very appreciated =). EDIT: Forgot to mention what is actually happening. Which is nothing. The ped is not starting to walk and that is what makes me wonder here.
  19. Extremo

    Hide map

    Hey, I am very sorry for not being clear. Yes I meant the map on F11. I'll go ahead and try the unbindKey immediatly! Thanks for the help, I'll report back as soon as I have some more news =). EDIT: Ok, it didn't work. Neither on the server nor on the client. Regards.
  20. Extremo

    Hide map

    Hey MTA Community, I would love to know if it is possible to make people not able to see the map at all. I don't only mean the radar map but also the one in the escape menu. Any help is very well appreciated. Please point me into the right direction too if it is possible. I already know you can hide the radar map with showPlayerHud, what I care most about is the map in the escape menu. Regards.
  21. If I am not to use module functions client-wise, how would I be able to communicate with the server then? I've read it somewhere before on wiki but can't seem to find it and would really appreciate if you could show me just a small example and elaborate it for me. Regards, Extremo. PS: I am gonna go straight ahead and see if it works server-side. EDIT: Right, I went ahead testing it server-side and it seems fine, except a few errors about the connection but I think I can figure them out Thanks alot EDIT 2: Fixed every Problem, now all I need is a small example of how to make the client and server work together with a small elaboration EDIT 3: Right I now also figured how to add events etc and make the client/server communicate. Thanks a lot, everything worked out well, there was just a slight misunderstanding
  22. Hello MTA Community, Today I've decided to actually get into MTA coding. So, as I already have experience in scripting such things, I wanted to start straight ahead into detail and test out if the MTA-MySQL module was working correctly. I made this small clientside script here: -- Testing MySQL Module function TestSQL(thePlayer, command) outputChatBox("#FF0000Works", thePlayer); con = mysql_connect("...","...","...","..."); outputChatBox("#FF0000Connection incomming....", thePlayer); if ( not con ) then -- The connection failed outputChatBox("#FF0000Unable to connect to the MySQL server", thePlayer); else outputChatBox("#FF0000Connected!", thePlayer); end outputChatBox("#FF0000ConnectedorNot", thePlayer); res2 = mysql_query("INSERT INTO cmd VALUES ('" .. getPlayerName( thePlayer ) .. "')"); if( not res2 ) then outputChatBox("#FF0000Unable to query 2", thePlayer); else outputChatBox("#FF0000Success", thePlayer); end outputChatBox("#FF0000Query", thePlayer); mysql_free_result(res2); mysql_close(con); outputChatBox("#FF0000end", thePlayer); end addCommandHandler("test", TestSQL); I obviously couldn't understand why exactly it was not functioning so I put up some chat msg's to see where its getting. Sadly, the only message I receive is the "Works" msg. I am assuming that the module crashes the function and makes it unable to finish executing, could that be in anyway possible and does anyone know a fix? For reference, the sql database is NOT local, its remote. I really have no clue how to fix this issue, as I would NOT want to use SQLlite and hope that you people out there are able to help me. I've searched around google which made me end up on a lot of topics around MTA but I couldn't find any topic(I am probably stupid) that showed me the exact problem with this bit of code. Regards, Extremo.
  23. Changing their nick from ingame. I dont care if they disconnect and change their name and come back, they should just not be able to do so ingame. If there isnt any feature for this then where is the suppose of a account system when he just goes changing his name and i cant find his acc anymore lol. Anyway, it might just help to add a event handler and just check when the person is changing his name and change it back. But is there any way to like cancel it fully?
  24. Is there a possibility to turn it off so you are not able to change your nick with /nick ingame? I have a login screen etc and its supposed to log you in etc and you shouldnt be able to play if you arent logged in and it would generally cause alot of trouble in my script. It would be nice to know if there is any possiblity to turn it off. Thanks in advance, Extremo.
  25. What was so hard that you couldn't understand it at my last message? Could you quote it out? I'll rephrase it for you.
×
×
  • Create New...