Jump to content

Problem to get target.


Sande

Recommended Posts

Hey, i am try to make a script what set to the target player element data true, but idk. If i do like /dea-oikeus1k-on Sisuviina goes just error, it just not found my name. Someone can help? i forget all about getTarget, or theres some weird error.

  
function deaOik(thePlayer, target, command) 
local target = getPlayerFromName ( target ) 
if ( target ) then 
setElementData(getPlayerFromName("target"), "DEAaccespass1", true) 
outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) 
else 
outputChatBox("VIRHE", thePlayer, 255,0,0) 
end 
end 
addCommandHandler("dea-oikeus1k-on", deaOik ) 
  
function deaOik1(thePlayer, target, command) 
local target = getPlayerFromName ( target ) 
if ( target ) then 
setElementData(getPlayerFromName("target"), "DEAaccespass1", false) 
outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) 
else 
outputChatBox("VIRHE", thePlayer, 255,0,0) 
end 
end 
addCommandHandler("dea-oikeus1k-of", deaOik1 ) 
  

Link to comment

No debug errors, it just not get the player, and puts error. i mean my own error message "VIRHE".

  
function deaOik(thePlayer, target, command) 
local target = getPlayerFromName ( "target" ) 
if ( target ) then 
setElementData(target, "DEAaccespass1", true) 
outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) 
else 
outputChatBox("VIRHE", thePlayer, 255,0,0) 
end 
end 
addCommandHandler("dea-oikeus1k-on", deaOik ) 
  
function deaOik1(thePlayer, target, command) 
local target = getPlayerFromName ( "target" ) 
if ( target ) then 
setElementData(target, "DEAaccespass1", false) 
outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) 
else 
outputChatBox("VIRHE", thePlayer, 255,0,0) 
end 
end 
addCommandHandler("dea-oikeus1k-of", deaOik1 ) 
  

Link to comment
No debug errors, it just not get the player, and puts error. i mean my own error message "VIRHE".
  
function deaOik(thePlayer, target, command) 
local target = getPlayerFromName ( "target" ) 
if ( target ) then 
setElementData(target, "DEAaccespass1", true) 
outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) 
else 
outputChatBox("VIRHE", thePlayer, 255,0,0) 
end 
end 
addCommandHandler("dea-oikeus1k-on", deaOik ) 
  
function deaOik1(thePlayer, target, command) 
local target = getPlayerFromName ( "target" ) 
if ( target ) then 
setElementData(target, "DEAaccespass1", false) 
outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) 
else 
outputChatBox("VIRHE", thePlayer, 255,0,0) 
end 
end 
addCommandHandler("dea-oikeus1k-of", deaOik1 ) 
  

Sorry, this was correct:

local target = getPlayerFromName ( target ) 

but, target has to be defined in the function name after command, I guess....

function deaOik(thePlayer, command, target)

Are you sure there's someone in the server with the name "target"? Try reconnecting with the resource running.

Link to comment

Idk, but it still going to "VIRHE" mean "ERROR".

function deaOik(thePlayer, command) 
local target = getPlayerFromName ( target ) 
if ( target ) then 
setElementData(target, "DEAaccespass1", true) 
outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) 
else 
outputChatBox("VIRHE", thePlayer, 255,0,0) 
end 
end 
addCommandHandler("dea-oikeus1k-on", deaOik ) 
  
function deaOik1(thePlayer, command) 
local target = getPlayerFromName ( target ) 
if ( target ) then 
setElementData(target, "DEAaccespass1", false) 
outputChatBox("[sERVER] Komento onnistui", thePlayer, 0,255,0) 
else 
outputChatBox("VIRHE", thePlayer, 255,0,0) 
end 
end 
addCommandHandler("dea-oikeus1k-of", deaOik1 ) 

Link to comment

This is wrong

function deaOik(thePlayer, target, command) 

Change to:

function deaOik(thePlayer, command, target) 

Server side the first argument is always the player ( the source ) who executes the command, second one is the command, 3rd one is the optional argument ( just like 4th, 5th etc)

Link to comment
This is wrong
function deaOik(thePlayer, target, command) 

Change to:

function deaOik(thePlayer, command, target) 

Server side the first argument is always the player ( the source ) who executes the command, second one is the command, 3rd one is the optional argument ( just like 4th, 5th etc)

I knew it :D

Question, why does it really matter which place you put the arguments?

Never-mind, just re-read your post.

Link to comment
This is wrong
function deaOik(thePlayer, target, command) 

Change to:

function deaOik(thePlayer, command, target) 

Server side the first argument is always the player ( the source ) who executes the command, second one is the command, 3rd one is the optional argument ( just like 4th, 5th etc)

Thank you very much! it works now :)

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