GCMod

Exports and Statebags

Public exports and statebag behavior for gcm_referral.


Exports

openReferralIntro() (client)
  • Signature: exports['gcm_referral']:openReferralIntro()
  • Context: client
  • Returns: nil
  • Behavior: Opens intro NUI and focuses cursor.
lua
-- client
exports['gcm_referral']:openReferralIntro()
getPlayerCode(source) (server)
  • Signature: exports['gcm_referral']:getPlayerCode(source)
  • Context: server
  • Returns: string|nil referral code
  • Failure cases: player not loaded or missing cached profile.
lua
-- server
local code = exports['gcm_referral']:getPlayerCode(source)
if code then
  print(('Referral code: %s'):format(code))
end
claimCode(source, code) (server)
  • Signature: exports['gcm_referral']:claimCode(source, code)
  • Context: server
  • Returns: boolean success, string message
  • Failure cases: own-code attempt, already claimed, invalid code.
lua
-- server
local ok, reason = exports['gcm_referral']:claimCode(source, 'GCM1234')
if not ok then
  print(('Claim failed: %s'):format(reason))
end
executeClaim(source, claimId) (server)
  • Signature: exports['gcm_referral']:executeClaim(source, claimId)
  • Context: server
  • Returns: boolean success, string message
  • Failure cases: missing claim, limit reached, unmet requirements.
lua
-- server
local ok, reason = exports['gcm_referral']:executeClaim(source, 1)
if not ok then
  print(('Execute claim failed: %s'):format(reason))
end

Statebags

LocalPlayer.state.isLoggedIn (client local state)
  • Owner: local player statebag
  • Observed writes: set to true on gcm_referral:load.
  • Observed reads: checked on resource start before triggering server load.
lua
-- read
if LocalPlayer.state.isLoggedIn then
  TriggerServerEvent('gcm_referral:load')
end
lua
-- write
LocalPlayer.state.isLoggedIn = true