bug: ND Core integration not saving phone numbers correctly
Opened this issue · 8 comments
Development Issue
Unsure
Phone Version
3.13.0
Issue Description
when using the ND Core integration, if you change character or disconnect from the server, phonenumber
in the database gets set to (NULL)
for the character that you were last on
Issue Reproduction
- select your character once you load into the server
- check DB and confirm a phone number has been added to your character
- change characters or disconnect from the server
- refresh the DB and confirm the phone number is now null for the character you were last on
- if disconnecting from server, see server console for error
Evidence
this is the error that comes up in server console when i disconnect from the server:
there doesn't appear to be any errors when i change character
logs when changing character: (didn't include anything that was "silly")
{"level":"info","message":"Unloaded NPWD Player, source: (1)","module":"player","timestamp":"2024-03-06T03:39:24.139Z"}
{"level":"debug","message":"ND Core Player Phone number: no phone number found","timestamp":"2024-03-06T03:39:24.144Z"}
{"level":"info","message":"Executed query (SELECT phonenumber FROM nd_characters WHERE charid = ? LIMIT 1 [\"19\"]) in 3.7121ms'","module":"DBInterface","timestamp":"2024-03-06T03:39:24.148Z"}
{"level":"debug","message":"Find user for number generation data >","module":"player","timestamp":"2024-03-06T03:39:24.148Z"}
{"level":"debug","message":[{"phonenumber":null}],"module":"player","timestamp":"2024-03-06T03:39:24.148Z"}
{"level":"debug","message":"Phone number was returned as null, generating new number","module":"player","timestamp":"2024-03-06T03:39:24.148Z"}
{"level":"info","message":"Executed query (SELECT EXISTS(SELECT * FROM nd_characters WHERE phonenumber = ?) [\"548-990-1689\"]) in 1.3398ms'","module":"DBInterface","timestamp":"2024-03-06T03:39:24.149Z"}
{"level":"debug","message":"Phone number generated > 548-990-1689","module":"player","timestamp":"2024-03-06T03:39:24.150Z"}
{"level":"info","message":"Executed query (UPDATE nd_characters SET phonenumber = ? WHERE charid = ? [\"548-990-1689\",\"19\"]) in 1.63ms'","module":"DBInterface","timestamp":"2024-03-06T03:39:24.151Z"}
{"level":"info","message":"New NPWD Player added through event (1) (19)","module":"player","timestamp":"2024-03-06T03:39:24.151Z"}
{"level":"debug","message":{"_firstname":"test","_identifier":"19","_lastname":"test","_phoneNumber":"548-990-1689","source":1,"username":"Jackson S."},"module":"player","timestamp":"2024-03-06T03:39:24.152Z"}
{"level":"info","message":"Executed query (\n SELECT *\n FROM npwd_twitter_profiles\n WHERE identifier = ?\n LIMIT 1\n\t\t [\"19\"]) in 2.0214ms'","module":"DBInterface","timestamp":"2024-03-06T03:39:24.237Z"}
{"level":"info","message":"Executed query (\n SELECT *\n FROM npwd_twitter_profiles\n WHERE identifier = ?\n LIMIT 1\n\t\t [\"19\"]) in 2.3135ms'","module":"DBInterface","timestamp":"2024-03-06T03:39:24.237Z"}
{"level":"info","message":"Executed query (\n SELECT \n npwd_twitter_tweets.id,\n npwd_twitter_tweets.identifier,\n npwd_twitter_profiles.id AS profile_id,\n npwd_twitter_profiles.profile_name,\n npwd_twitter_profiles.avatar_url,\n npwd_twitter_tweets.likes,\n npwd_twitter_tweets.visible,\n IFNULL(COALESCE(retweets.message, npwd_twitter_tweets.message), '') AS message,\n IFNULL(COALESCE(retweets.images, npwd_twitter_tweets.images), '') AS images,\n npwd_twitter_tweets.retweet IS NOT NULL AS isRetweet,\n retweets.id AS retweetId,\n retweets_profiles.profile_name AS retweetProfileName,\n retweets_profiles.avatar_url AS retweetAvatarUrl,\n npwd_twitter_likes.id IS NOT NULL AS isLiked,\n npwd_twitter_reports.id IS NOT NULL AS isReported,\n npwd_twitter_tweets.createdAt,\n npwd_twitter_tweets.updatedAt,\n TIME_TO_SEC(TIMEDIFF( NOW(), npwd_twitter_tweets.createdAt)) AS seconds_since_tweet\n\n FROM npwd_twitter_tweets\n LEFT OUTER JOIN npwd_twitter_profiles\n ON npwd_twitter_tweets.identifier = npwd_twitter_profiles.identifier\n LEFT OUTER JOIN npwd_twitter_likes ON npwd_twitter_tweets.id = npwd_twitter_likes.tweet_id AND\n npwd_twitter_likes.profile_id = ?\n LEFT OUTER JOIN npwd_twitter_reports ON npwd_twitter_tweets.id = npwd_twitter_reports.tweet_id AND\n npwd_twitter_reports.profile_id = ?\n LEFT OUTER JOIN npwd_twitter_tweets AS retweets ON retweets.id = npwd_twitter_tweets.retweet\n LEFT OUTER JOIN npwd_twitter_profiles AS retweets_profiles\n ON retweets.identifier = retweets_profiles.identifier\n WHERE npwd_twitter_tweets.visible = 1\n ORDER BY id DESC\n LIMIT ? OFFSET ?\n\t\t [7,7,\"25\",\"0\"]) in 1.5782ms'","module":"DBInterface","timestamp":"2024-03-06T03:39:24.239Z"}
{"level":"info","message":"Executed query (SELECT * FROM npwd_phone_contacts WHERE identifier = ? ORDER BY display ASC [\"19\"]) in 3.168ms'","module":"DBInterface","timestamp":"2024-03-06T03:39:24.289Z"}
{"level":"info","message":"Executed query (SELECT npwd_messages_conversations.id,\n npwd_messages_conversations.conversation_list as conversationList,\n npwd_messages_participants.unread_count as unreadCount,\n npwd_messages_conversations.is_group_chat as isGroupChat,\n npwd_messages_conversations.label,\n UNIX_TIMESTAMP(npwd_messages_conversations.updatedAt) as updatedAt,\n npwd_messages_participants.participant\n FROM npwd_messages_conversations\n INNER JOIN npwd_messages_participants\n on npwd_messages_conversations.id = npwd_messages_participants.conversation_id\n WHERE npwd_messages_participants.participant = ? [\"548-990-1689\"]) in 5.1826ms'","module":"DBInterface","timestamp":"2024-03-06T03:39:24.291Z"}
{"level":"info","message":"Executed query (\n SELECT *,\n UNIX_TIMESTAMP(updatedAt) AS lastActive\n FROM npwd_match_profiles\n WHERE identifier = ?\n LIMIT 1\n\t\t [\"19\"]) in 5.8734ms'","module":"DBInterface","timestamp":"2024-03-06T03:39:24.292Z"}
logs when disconnecting from server:
{"level":"info","message":"Unloaded NPWD Player, source: (1)","module":"player","timestamp":"2024-03-06T03:49:59.125Z"}
Also having this issue. Investigated the script's handleUnloadPlayerEvent and deleteFromMaps but cannot find where this would lead to setting a NULL
value...
Update
Another player notes it is specifically the nd_character
integration, as ND_Core alone doesn't do this.
How does ND Core even handle saving players? I'm guessing whatever method theyre using for saving characters is just overwriting this column which shouldn't be hard fix at all. You just need to save that portion too by updating db. Not really related to NPWD.
How does ND Core even handle saving players? I'm guessing whatever method theyre using for saving characters is just overwriting this column which shouldn't be hard fix at all. You just need to save that portion too by updating db. Not really related to NPWD.
ah, that would make sense
@Andyyy7666 would you be able to look into this?
but for the error screenshot i attached, could that be caused by what you mentioned or would that be an NPWD issue?
cause that only happens when disconnecting from the server
Yes, ND Core is updating the phonenumber column to null. This is because the phonenumber isn't being set in the ND player data.
Is it possible to assign the phonenumber to the player data within the ND_Core as a pass-thru or does this have to be done within NPWD with whatever number it generates within its own code?
Maybe if we could get the phone number here https://github.com/project-error/npwd/blob/master/apps/game/server/players/player.service.ts#L208
(A lazy workaround for now)
Commented out line 194 NDCore/server/player.lua
--self.phonenumber,
so it does not overwrite the value set in DB on disconnect , sticks with static phone number set
I tried doing that workaround but the error seems to keep popping up. It happens when players leave the server