'Pos' is not a member of player

Started by Kewun, Aug 05, 2016, 02:13 PM

Previous topic - Next topic

Kewun

function ChooseTriads(player)
{
   player.Skin = 13;
   player.Team = 2;
   player.Pos = Vector(870.70,-540.70,14.97)   // here, the error
   MessagePlayer("You choosed team Triads!",player)
}

error is on the player.Pos line, as in topic title "'Pos' is not a member of player"
 im trying to make a gui on spawn screen, to make plrs click buttons what select spawn skins classes
and this is the error

if you want more functions,
function onPlayerChooseTeam(player,key,team)
{
if ( key == "0x6F5330" )
{
if ( team == "Triads" )
{
player.Spawn();
NewTimer("ChooseTriads", 500, 1, player)
}
if ( team == "Diablos" )
{
player.Spawn();
NewTimer("ChooseDiablos", 500, 1, player)
}
if ( team == "Mafia" )
{
player.Spawn();
NewTimer("ChooseMafia", 500, 1, player)
}
}
}

i use this, in the server side.

i use the "key", bcs im doing this for lu, and there is a client exploit.

client:

function onScriptLoad()
{
test <- GUIButton(VectorScreen(10,500), ScreenSize(60,60), "Triads")
//test.Active = false
AddGUILayer(test)
test.Visible = true;
test.SetCallbackFunc( "onPlayerChoose" )
ShowMouseCursor(true)
}
function onPlayerChoose()
{
ShowMouseCursor(false)
test.Visible=false
CallServerFunc("Main/server.nut", "onPlayerChooseTeam", FindLocalPlayer(), "0x6F5330", "Triads")
}

what is the problem? :(

Stormeus

Passing an entire player object to a timer is bad practice for a couple of reasons:
  • Timers don't support passing objects in VC:MP.
  • Even if they were supported (like in LU?), you run the risk of the player disconnecting before the timer is called, which invalidates the object and causes the server to crash.

When you create the timer for ChooseTriads, you should be passing player.ID to the function, and then use FindPlayer to make sure they're still connected. You can reuse the player object from there.

Kewun

so, i will have to use NewTimer("ChooseTriads", 500, 1, player.ID) ? i dont really understand ;c ;v

EK.IceFlake

function ChooseTriads(playername, playerid)
{
   local player = FindPlayer(playerid);
   if (player == null || player.Name != playername) return 0;
   player.Skin = 13;
   player.Team = 2;
   player.Pos = Vector(870.70,-540.70,14.97);
   MessagePlayer("You choosed team Triads!",player);
}
Usage:
NewTimer("ChooseTriads", 500, 1, player.Name, player.ID); By the way I recommend you use semicolons

.

God, I forgot how primitive this thing was :D You might consider: http://forum.vc-mp.org/?topic=1487.0
.

Xmair

Why are you using a timer there and not calling the function directly?

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Kewun

idk, because i think, the functions lag

KAKAN

Quote from: Kewun on Aug 05, 2016, 04:59 PMidk, because i think, the functions lag
then using a timer will cause it to lag less? Not going to happen as Squirrel is not multi-threaded. Timers run on the same thread :D
oh no

Kewun