Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Kewun on Aug 05, 2016, 02:13 PM

Title: 'Pos' is not a member of player
Post by: Kewun on Aug 05, 2016, 02:13 PM
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? :(
Title: Re: 'Pos' is not a member of player
Post by: Stormeus on Aug 05, 2016, 02:22 PM
Passing an entire player object to a timer is bad practice for a couple of reasons:

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.
Title: Re: 'Pos' is not a member of player
Post by: Kewun on Aug 05, 2016, 02:25 PM
so, i will have to use NewTimer("ChooseTriads", 500, 1, player.ID) ? i dont really understand ;c ;v
Title: Re: 'Pos' is not a member of player
Post by: EK.IceFlake on Aug 05, 2016, 02:31 PM
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
Title: Re: 'Pos' is not a member of player
Post by: . on Aug 05, 2016, 04:12 PM
God, I forgot how primitive this thing was :D You might consider: http://forum.vc-mp.org/?topic=1487.0
Title: Re: 'Pos' is not a member of player
Post by: Xmair on Aug 05, 2016, 04:22 PM
Why are you using a timer there and not calling the function directly?
Title: Re: 'Pos' is not a member of player
Post by: Kewun on Aug 05, 2016, 04:59 PM
idk, because i think, the functions lag
Title: Re: 'Pos' is not a member of player
Post by: KAKAN on Aug 05, 2016, 05:37 PM
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
Title: Re: 'Pos' is not a member of player
Post by: Kewun on Aug 05, 2016, 07:05 PM
fixed, thx all