Sir Bugg
Veteran • Software Engineer
- Joined
- Sep 22, 2008
- Messages
- 9
- Reaction score
- 1
Using TFS 1.3 - This may be a tricky one to explain, but let's see how it goes.
I've searched the forums up and down but haven't quite found what I'm looking for. Creating a variable for playerdata returns nil unless that player is actually online.
For example, it's the playerdata table that's created when you declare a variable like this:
The only drawback is that you can only create this when the player with a matching player_id is online. Otherwise you can't use the variable becuase it's returned with nil.
Question:
Is it possible to create the same Player() data without the player being online?
If so, how is this done (without source edits) or could someone please direct me to where I might find the direction to do so?
If this is not possible, how else can this be achieved? All I could find were some posts mentioning source edits but wasn't sure if that would work or potentially cause other unknown errors. I'd like to do this within a lua script.
I'm fairly certain that what I'm wanting to do will require a database query, but that shouldn't be anything more than retrieving the player's id or name, etc.
Something like this:
However, I'm unable to create an instance of the player using the queried data like this: local player = Player(q_Id) unless that player is actually online.
So, how can I accomplish this if the player is not online? Is it possible to create a tempPlayer to store this player data somehow?
Does anyone have any suggestions?
Thank you.
I've searched the forums up and down but haven't quite found what I'm looking for. Creating a variable for playerdata returns nil unless that player is actually online.
For example, it's the playerdata table that's created when you declare a variable like this:
Lua:
local player = Player(player_id)
The only drawback is that you can only create this when the player with a matching player_id is online. Otherwise you can't use the variable becuase it's returned with nil.
Question:
Is it possible to create the same Player() data without the player being online?
If so, how is this done (without source edits) or could someone please direct me to where I might find the direction to do so?
If this is not possible, how else can this be achieved? All I could find were some posts mentioning source edits but wasn't sure if that would work or potentially cause other unknown errors. I'd like to do this within a lua script.
I'm fairly certain that what I'm wanting to do will require a database query, but that shouldn't be anything more than retrieving the player's id or name, etc.
Something like this:
Lua:
-- get offline player's Id
local dbQuery_1 = db.storeQuery("SELECT `player_id` FROM `players` WHERE `name` = "..playerName.." LIMIT 1;")
local q_Id = result.getDataInt(dbQuery_1, "player_id")
result.free(dbQuery_1)
So, how can I accomplish this if the player is not online? Is it possible to create a tempPlayer to store this player data somehow?
Does anyone have any suggestions?
Thank you.
Last edited: