getting xyz player in script

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
hardbassbv
Private
Posts: 1
Joined: Tue Jun 30, 2009 3:05 pm

getting xyz player in script

Post by hardbassbv »

hello,

is there a way to get te players x y z through a script
someting like

Code: Select all


if (int(getcvar(MYTHING)) > 0)
{
	setcvar "MYTHING" "0"
	iprintlnbold "if u see this it works :P"
	setcvar "ply_pos" "X Y Z"
}

so if i do the rcon comand "rcon mything 1"
then he says "if u see this it works :P"
and in the var "ply_pos" comes the position of the player who did the command

is that possible or must i do that on another way?

and my second question:
if i do "&player.origin" it return my position
but if there more players than one it fails

can you replace the & for a id of a player
cause if thats treu i can make someting like this

Code: Select all


if (int(getcvar(MYTHING)) > 0)
{
	setcvar "MYTHING" "0"
	iprintlnbold "if u see this it works :P"
	setcvar "ply_pos" getcvar(mything)player.origin
}

and than in than in the rcon i make mythig the mumber of my id

(srry for bd english)"[/code]
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Yes, just retrieve the origin property, however "comes the position of the player who did the command" won't work since you cannot find out which player on the server has logged on as admin and commanded the console.
(ie. You cannot get any cvar information from the clients through scripting and both "rconaddress" and "password" are cvars).

Perhaps through the Admin Pro Menu, I recall it having some sort of admin system.

&player.origin?? I'm doubtful that would return your origin.
1) you forgot the kind of variable: local.
2) What is that & doing there?
3) You are asking how to access all players, so obviously this would only work if you defined local.player = parm.other in a trigger.

All players are tallied in the $player array. Therefore you'll have to scan this array to find yourself or someone else. Since the first person to enter the server is $player[1], the second $player[2] etc... but if the first player leaves, the array automatically adjusts it, so the second player becomes $player[1] and so on (in other words, the array doesn't leave any gaps).

Basically you'll need some property to find a certain player and since .netname only works in BT and a patched SH it's harder than you think.
If you just want a random player, just pick a random $player array slot.

Code: Select all

for (local.i = 1; local.i <= $player.size; local.i++)
{
     if ( $player[local.i].blah == local.blah ) //we got our man
     {
             //....
     }
}
or pick a random guy:

Code: Select all

local.guy = $player[(randomint($player.size) + 1)]
or a random guy's origin:

Code: Select all

local.guy = $player[(randomint($player.size) + 1)].origin
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
Post Reply