Jump to content

Some questions


Fabio(GNR)

Recommended Posts

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 :D 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

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
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 :D

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 :P

but whatsup with the bad argument?? :o

EDIT3: ok found ispedonground, testing now :D

EDIt4:ok, lol 4th edit, i quit on random pos, it get;s kinda complicated for such something kinda useless haha :P thanks for marker info, and god-mode thing, i will check back tomorrow :D 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

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
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
 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
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? :oops:

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 :o btw, should it be only resistant against guns etc.

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