Jump to content

Target system


Recommended Posts

Hi.

I need something like that: When you're logined, the system put's every player into a Team and every team has a randomly selected player target. Or it can be made without teams?

Is this possible? I Don't know how to start. I just know Pawno but lua. I've watched a lot of tutorial but can't make my own.

I would be very thankful if anybody helps.

Nick

Link to comment

There we are. I started it. I want that if the resource starts everyone got a target. You have one target, and this can't be yourself. Then if everyone has a target, and a new player joins he got a target. It doesn't matter that he has the same target that somebody else, but want to limit this number. So 3 men could have the same target. And when somebody kills his target he gots the recently joined new player as a target. I'm stepping into a big task, but i belive that i can make it with help. I like to start things in the middle. So i started learning lua from here.

I have this so far:

Meta.xml

    "--" version="1.0" type="script" description="Target system"/> 
    

target.lua

   addEventHandler ( "onResourceStart", resourceRoot, 
    function () 
        for index, player in pairs(getElementsByType("player")) do 
             while true do 
                   local randomTarget = getRandomPlayer ( ) 
                   if randomTarget ~= player then 
                        outputChatBox ("Your target is: " ..getPlayerName ( randomTarget ), player ) 
                        break 
                   end 
              end 
         end 
    end 
) 
)  

Stuck at the beggining. Any tips?

EDIT: So far made by Alpha

Edited by Guest
Link to comment

Your script is server side, onClientResourceStart is a client side event.

Server side:

addEventHandler ( "onResourceStart", resourceRoot, 
    function () 
        for index, player in pairs(getElementsByType("player")) do 
             while true do 
                   local randomTarget = getRandomPlayer ( ) 
                   if randomTarget ~= player then 
                        outputChatBox ("Your target is: " ..getPlayerName ( randomTarget ), player ) 
                        break 
                   end 
              end 
         end 
    end 
) 

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