Fabio(GNR) Posted October 2, 2010 Share Posted October 2, 2010 Im trying to create a command that teleport's to random location, if it works and the player get's in water it should be teleported to my coordinates, how to get a random position? i searched at wiki didnt found anything, only math.random but that doesn't work, and is there any way to check if you are under the ground?? Code: x = math.random y = math.random z = math.random function randompos (source) outputChatBox ("You Have Been Teleported To A Random Place??", playerSource, 0, 255, 0) setElementPosition (source, x, y, z) if isElementInWater(source) then setElementPosition (source, 318.9296875,2480.2568359375,16.059270858765) outputChatBox ("You got in water, teleported back to AA!!", playerSource, 0, 255, 0) end end addCommandHandler ( "random", randompos ) It, ofcourse, give's me Bad Argument at set element position... EDIt: ok 2 small questions, i want to ckeck if player is in a team called god, and then run god-mode: I don't really have anything except this: function damag() cancelEvent() end Thats the god mode, i searched on wiki, but only found ckeck if in a team, and get teamname EDIt2: alot's of question now lol, i have created a script that gives player money when they enter marker, it has to destroy the element when it's hit, timer for 40 second's create new marker and again it should give money, it all works but destroyelement doesn't, it says : [18:36:07] WARNING: 229: Bad 'element' pointer @ 'destroyElement'(1) code: local money2 = createMarker ( 3103.23828125,-7449.2583007813,31.392185211182, "checkpoint", 15, 255, 255, 0, 170 ) function blipper ( getRootElement, myPlayer ) Blipfinish1 = createBlip ( 5316.9272460938,4005.6030273438,49.187973022461, 53, 2, 0, 0, 0, 255, 0, 1500, myPlayer ) Blipfinish2 = createBlip ( 3103.23828125,-7449.2583007813,31.392185211182, 53, 2, 0, 0, 0, 255, 0, 8000, myPlayer ) end function money2newmarker() local money2 = createMarker ( 3103.23828125,-7449.2583007813,31.392185211182, "checkpoint", 15, 255, 255, 0, 170 ) --setTimer ( moneylongdrag2, 0030, 1 ) NOT USED addEventHandler("onMarkerHit", money2, moneylongdrag) end function moneylongdrag(hitElement, matchingDimension) if getElementType(hitElement)=="player" then givePlayerMoney ( hitElement, 40000 ) destroyElement ( money2 ) setTimer ( money2newmarker, 4000, 1 ) end end function moneylongdragl(hitElement, matchingDimension) if getElementType(hitElement)=="player" then givePlayerMoney ( hitElement, 40000 ) destroyElement ( money2l ) setTimer ( money2newmarker, 4000, 1 ) end end addEventHandler("onMarkerHit", money2, moneylongdrag) addEventHandler ( "onResourceStart", resourceRoot2, blipper ) btw, it does destroy it when i kill the marker that i created first but not the one from money2newmarker Link to comment
dzek (varez) Posted October 2, 2010 Share Posted October 2, 2010 3.) remove "local" before any money2 marker. not sure if it wont mess up other thing. read about locals etc in general lua manual (search google) 1.) search wiki for something like "get ground position" and remember to get ground position your player have to be near that position, so you can teleport, and 1 sec after teleport - get ground position. this funciton was only clientside. 2.) onPedDamage or onPlayerDamage (not sure) - cancel it if getTeamName(getPlayerTeam(your_player_element)) == "god" - it will be better if made client side (onClientPedDamage) - but you cant get player team clientside AFAIR - so you can store it on element data on server side, and read on client side Link to comment
Fabio(GNR) Posted October 2, 2010 Author Share Posted October 2, 2010 3.) remove "local" before any money2 marker. not sure if it wont mess up other thing. read about locals etc in general lua manual (search google)1.) search wiki for something like "get ground position" and remember to get ground position your player have to be near that position, so you can teleport, and 1 sec after teleport - get ground position. this funciton was only clientside. 2.) onPedDamage or onPlayerDamage (not sure) - cancel it if getTeamName(getPlayerTeam(your_player_element)) == "god" - it will be better if made client side (onClientPedDamage) - but you cant get player team clientside AFAIR - so you can store it on element data on server side, and read on client side Ok than for all the info trying/reading everything now edit1: code for god is now : function createTeamsOnStart () teamgod = createTeam ( "God-mode on", 0, 255, 0 ) teamnormal = createTeam ( "Normal (allowed to Deathmatch)", 200, 0, 100 ) end function godnormal(playerSource) setPlayerTeam ( playerSource, teamgod ) -- add the player to the new team end function normalgod(playerSource) setPlayerTeam ( playerSource, teamnormal ) -- add the player to the new team end addCommandHandler ( "god", godnormal ) addCommandHandler ( "godoff", normalgod ) function damag(attacker, weapon, bodypart, playerSource) if getTeamName(getPlayerTeam(source)) == "teamgod" then cancelEvent() end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) --we attach the function to this resource's root element addEventHandler("onPlayerDamage", getRootElement(), damag) thats currently server side, error message: [10:43:16] WARNING: theserver\god.lua:20: Bad argument @ 'getPlayerTeam [10:43:16] WARNING: theserver\god.lua:20: Bad argument @ 'getTeamName' EDIT2: Thanks, the marker works now but whatsup with the bad argument?? EDIT3: ok found ispedonground, testing now EDIt4:ok, lol 4th edit, i quit on random pos, it get;s kinda complicated for such something kinda useless haha thanks for marker info, and god-mode thing, i will check back tomorrow btw, wiki is down again EDIt5: another question: (wiki down srry) code: function skinelve(playerSource) setElementModel (playerSource, 84) end addCommandHandler("elvis", skinelve) function skintimer() setTimer(skincheck, 5000, 1) end function skincheck( source ) local skin = getElementModel ( source ) if (skin == 84) then setPedSkin(source, 0) end end addCommandHandler("check", skincheck) addEventHandler ( "onResourceStart", getRootElement(), skincheck ) I don't know what to use instead of source, i know it's wrong, but what should i use? for the eventhandler btw, it check at every resource, at every player... Link to comment
Fabio(GNR) Posted October 5, 2010 Author Share Posted October 5, 2010 BUMP, please help (wiki still down) Link to comment
CowTurbo Posted October 6, 2010 Share Posted October 6, 2010 use thePlayer function skinelve(thePlayer) setElementModel (thePlayer, 84) end addCommandHandler("elvis", skinelve) function skintimer() setTimer(skincheck, 5000, 1) end function skincheck( thePlayer ) local skin = getElementModel ( thePlayer ) if (skin == 84) then setPedSkin(thePlayer, 0) end end addCommandHandler("check", skincheck) addEventHandler ( "onResourceStart", getRootElement(), skincheck ) Link to comment
Fabio(GNR) Posted October 6, 2010 Author Share Posted October 6, 2010 use thePlayer function skinelve(thePlayer) setElementModel (thePlayer, 84) end addCommandHandler("elvis", skinelve) function skintimer() setTimer(skincheck, 5000, 1) end function skincheck( thePlayer ) local skin = getElementModel ( thePlayer ) if (skin == 84) then setPedSkin(thePlayer, 0) end end addCommandHandler("check", skincheck) addEventHandler ( "onResourceStart", getRootElement(), skincheck ) Lol i thought that always was for tut's and stuff Thanks (btw the elvis script works ) EDIT: btw, do you know anything to check it some time's or onPlayerJoin? Thanks EDIt2: got it working, with source though at onplayerjoin, code: function skinelve(playerSource) setElementModel (playerSource, 84) end addCommandHandler("elvis", skinelve) function skintimer() setTimer(skincheck, 5000, 1) end function skincheck( thePlayer ) -- if hasObjectPermissionTo( thePlayer, "general.lol" ) then local skin = getElementModel ( source ) if (skin == 84) then setPedSkin ( source, 0 ) end end -- end addCommandHandler("check", skincheck) addEventHandler ( "onPlayerJoin", getRootElement(), skincheck ) function gnristhebest() --LOLZ end thanks for the help can you help me with my other question's, sorry but im kinda stuck Link to comment
CowTurbo Posted October 6, 2010 Share Posted October 6, 2010 sure ask it here, so everyone can answer Link to comment
Fabio(GNR) Posted October 6, 2010 Author Share Posted October 6, 2010 function createTeamsOnStart () teamgod = createTeam ( "Fun Players", 0, 255, 0 ) teamDM = createTeam ( "Deathmatching Players", 200, 0, 100 ) end function godnormal(playerSource) setPlayerTeam ( playerSource, teamgod ) end function normalgod(playerSource) setPlayerTeam ( playerSource, teamDM ) end addCommandHandler ( "god", godnormal ) addCommandHandler ( "dm", normalgod ) function damag(attacker, weapon, bodypart, playerSource) if getTeamName(getPlayerTeam(source)) == "teamgod" then cancelEvent() end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) --we attach the function to this resource's root element addEventHandler("onPlayerDamage", getRootElement(), damag) That has to create 2 teams, and if you are in team god, it should give you god-mode So cancel event on damage of everyone in that team. Link to comment
Fabio(GNR) Posted October 7, 2010 Author Share Posted October 7, 2010 so, it doesnt cancel? it gives me this error: (when damag is triggered) [2010-10-05 20:26:20] WARNING: theserver\god.lua:22: Bad argument @ 'getTeamName' btw thanks for quick response!! Link to comment
dzek (varez) Posted October 7, 2010 Share Posted October 7, 2010 this probably is returning false: getPlayerTeam(source) so i think player doesnt have any team https://wiki.multitheftauto.com/wiki/Debugging Link to comment
Fabio(GNR) Posted October 8, 2010 Author Share Posted October 8, 2010 yes i used debugging, and it gave me that error on damage, and i am in the team fun/god, thanks though Link to comment
dzek (varez) Posted October 8, 2010 Share Posted October 8, 2010 Debugging ~= debug window. debug window is only a small part in the art of debugging. read even 1000 times until you get what im saying. Link to comment
Fabio(GNR) Posted October 8, 2010 Author Share Posted October 8, 2010 Debugging ~= debug window.debug window is only a small part in the art of debugging. read even 1000 times until you get what im saying. uhm, i read alot, but i don't know what to do output the string? or the if? EDIT: should it be source (on getplayerteam) or not? if i use playerSource, it says bad argument, but at source it doesnt give error, but doesn't cancel the event... EDIt2: ok found something, it doesn't trigger it unless i made an error in it ???? anyway, if i delete the if part and just keep cancalEvent it still doesnt work btw, should it be only resistant against guns etc. 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