{"id":9904,"date":"2024-02-05T09:20:01","date_gmt":"2024-02-05T08:20:01","guid":{"rendered":"https:\/\/esx-scripts.com\/?p=9904"},"modified":"2025-08-27T08:44:21","modified_gmt":"2025-08-27T06:44:21","slug":"conserto-do-crewphone","status":"publish","type":"post","link":"https:\/\/fivemx.com\/pt\/crewphone-fix\/","title":{"rendered":"CrewPhone: Solu\u00e7\u00e3o essencial para o problema de hash imposs\u00edvel"},"content":{"rendered":"<p><strong>How to Fix CrewPhone Hash Problem (###)<\/strong>  <\/p>\n<p>Many players who use the CrewPhone (or gcPhone) addon on their FiveM servers find themselves staring at a seemingly random number like <strong>###-####<\/strong> instead of the expected full phone number. It\u2019s a subtle but disruptive glitch that stops players from being able to place calls, send messages, or use the in\u2011game phone at all. If you\u2019ve hit this snags, you\u2019re not alone, and the solution is quite straightforward.  <\/p>\n<p>&#8212;<\/p>\n<h2>CrewPhone Hash Problem: Quick Fix  <\/h2>\n<p>The culprit is usually a missing client\u2011side event that tells the server when a player has fully loaded into the game. Without this tiny notification, the server-side script that generates phone numbers often falls back to a default sequence, producing the placeholder numbers you see. The fix is to fire a server event as soon as the player\u2019s loadout has been restored.  <\/p>\n<p>Here\u2019s the full, ready\u2011to\u2011copy snippet you can drop into your `client.lua` (or an equivalent Es_extended client script):  <\/p>\n<p>&#8220;`lua<br \/>\n&#8212; Trigger a server event as soon as the player has loaded<br \/>\nTriggerServerEvent(&#8216;crew:onPlayerLoaded&#8217;, GetPlayerServerId(PlayerId()))<\/p>\n<p>&#8212; Example: Attach to the existing loadout restoration hook<br \/>\nAddEventHandler(&#8216;esx:restoreLoadout&#8217;, function()<br \/>\n    local playerPed   = PlayerPedId()<br \/>\n    local ammoTypes   = {}<\/p>\n<p>    &#8212; Remove any pre\u2011existing weapons<br \/>\n    RemoveAllPedWeapons(playerPed, true)<\/p>\n<p>    &#8212; Re\u2011give the player their loadout<br \/>\n    for _, weapon in ipairs(ESX.PlayerData.loadout) do<br \/>\n        local weaponName = weapon.name<br \/>\n        local ammoType   = GetPedAmmoTypeFromWeapon(playerPed, weaponName)<\/p>\n<p>        &#8212; Add weapon to the ped<br \/>\n        GiveWeaponToPed(playerPed, weaponName, 0, false, false)<br \/>\n        SetPedWeaponTintIndex(playerPed, weaponName, weapon.tintIndex)<\/p>\n<p>        &#8212; Add any weapon components<br \/>\n        for _, component in ipairs(weapon.components) do<br \/>\n            local componentHash = ESX.GetWeaponComponent(weaponName, component).hash<br \/>\n            GiveWeaponComponentToPed(playerPed, weaponName, componentHash)<br \/>\n        end<\/p>\n<p>        &#8212; Add ammo only once per type<br \/>\n        if not ammoTypes[ammoType] then<br \/>\n            AddAmmoToPed(playerPed, weaponName, weapon.ammo)<br \/>\n            ammoTypes[ammoType] = true<br \/>\n        end<br \/>\n    end<\/p>\n<p>    &#8212; Tell the server the player has fully loaded<br \/>\n    TriggerServerEvent(&#8216;crew:onPlayerLoaded&#8217;, GetPlayerServerId(PlayerId()))<\/p>\n<p>    isLoadoutLoaded = true<br \/>\nend)<br \/>\n&#8220;`<\/p>\n<p>All you need to do is paste this block above the rest of your client\u2011side code, ensuring it runs immediately after the player\u2019s data is fully restored.  <\/p>\n<p>&#8212;<\/p>\n<h2>Why the Event is Crucial  <\/h2>\n<p>In a typical FiveM server running Es_extended, player data (including the phone number) is stored on the server and fetched each time a player joins. The client script then sends a \u201cplayer loaded\u201d event back to the server so that the server knows all required assets (weapons, clothes, phone data) have been applied.  <\/p>\n<p>If that event is missing, the server can\u2019t correctly link the phone number to the player object\u2014leading it to fall back to either:  <\/p>\n<p>1. <strong>A default, unreadable hash<\/strong> (the infamous `###-####`), or<br \/>\n2. <strong>No number at all,<\/strong> which forces the client to request a new one, causing the same glitch again.  <\/p>\n<p>By firing `crew:onPlayerLoaded` at the right moment, you give the server a chance to bind the freshly loaded player object to its stored phone number. The hash conversion portion of the script then correctly transforms that number into a readable format.  <\/p>\n<p>&#8212;<\/p>\n<h2>Step\u2011by\u2011Step Setup Guide  <\/h2>\n<p>1. <strong>Locate Your Client Script<\/strong><br \/>\n   Find the `client.lua` (or a similarly named file) within your `es_extended` or `CrewPhone` resource folder.  <\/p>\n<p>2. <strong>Insert the Trigger<\/strong><br \/>\n   At the very top of the file, add:<br \/>\n   &#8220;`lua<br \/>\n   TriggerServerEvent(&#8216;crew:onPlayerLoaded&#8217;, GetPlayerServerId(PlayerId()))<br \/>\n   &#8220;`<br \/>\n   This ensures the event fires even before any other logic runs.  <\/p>\n<p>3. <strong>Update the Loadout Hook<\/strong><br \/>\n   Search for the `AddEventHandler(&#8216;esx:restoreLoadout&#8217;, function()` line.<br \/>\n   Replace or augment the handler with the complete example shown above.  <\/p>\n<p>4. <strong>Save and Reload<\/strong><br \/>\n   Save the file, then run the following in your server console:<br \/>\n   &#8220;`bash<br \/>\n   apply_pgsql<br \/>\n   restart CrewPhone<br \/>\n   restart es_extended<br \/>\n   &#8220;`<br \/>\n   Alternatively, simply restart the entire server to ensure all changes take effect.  <\/p>\n<p>5. <strong>Test<\/strong><br \/>\n   Join the server, equip a weapon, and open your in\u2011game phone. The number should now appear correctly, e.g., `012-3456`.  <\/p>\n<p>&#8212;<\/p>\n<h2>Troubleshooting Common Issues  <\/h2>\n<p>| Problem | Possible Cause | Fix |<br \/>\n|&#8212;&#8212;&#8212;|&#8212;&#8212;&#8212;&#8212;&#8212;-|&#8212;&#8211;|<br \/>\n| Phone number still shows as `###-####` | Event not firing (e.g., script order wrong) | Double\u2011check that the `TriggerServerEvent` line appears above any other function definitions. |<br \/>\n| Server logs show `ERROR: crew:onPlayerLoaded` | Mis\u2011named event on the server side | Verify that the <a href=\"https:\/\/fivemx.com\/setting-up-fxmanifest-lua-fivem\/\" title=\"Setting Up fxmanifest.lua (FiveM)\"  data-wpil-monitor-id=\"1559\">server script<\/a> listens for `crew:onPlayerLoaded` (usually in `server.lua`). |<br \/>\n| Player receives a <strong>different<\/strong> number each time | Number regeneration on load | Ensure `crew:onPlayerLoaded` triggers only after the loadout is fully applied; the snippet above handles this. |<br \/>\n| Game crashes when loading weapons | Incorrect weapon hash or component value | Confirm the ESX version you\u2019re using matches the snippet\u2019s API (some older versions use `GetWeaponComponent`.) |<\/p>\n<p>&#8212;<\/p>\n<h2>Alternatives if the Script Doesn\u2019t Work  <\/h2>\n<p>Although the above solution works for most setups, you might still face challenges if your server runs custom scripts or a different framework. Here are a couple of alternative approaches:  <\/p>\n<p>1. <strong>Directly Call the Phone Registration Function<\/strong><br \/>\n   &#8220;`lua<br \/>\n   TriggerServerEvent(&#8216;crew:registerPhone&#8217;, GetPlayerServerId(PlayerId()))<br \/>\n   &#8220;`<br \/>\n   Some CrewPhone variants expose a `registerPhone` event that forces the server to generate a new number regardless of the loadout status.  <\/p>\n<p>2. <strong>Patch the Server\u2011Side Number Generator<\/strong><br \/>\n   Locate the server script that handles `crew:onPlayerLoaded` and ensure it includes:<br \/>\n   &#8220;`lua<br \/>\n   if not playerData.phone then<br \/>\n       playerData.phone = GeneratePhoneNumber()<br \/>\n   end<br \/>\n   TriggerClientEvent(&#8216;crew:setPhoneNumber&#8217;, src, playerData.phone)<br \/>\n   &#8220;`<br \/>\n   This forces a proper number to be set even if the client didn\u2019t request one.  <\/p>\n<p>&#8212;<\/p>\n<h2>Expanding Beyond the Hash Problem  <\/h2>\n<p>Fixing the hash problem is just one part of having a polished phone system on your server. To get the meeste value out of CrewPhone, consider adding:  <\/p>\n<p>&#8211; <strong>Custom Call Sounds<\/strong> \u2013 Replace the default ringtone with localized genres.<br \/>\n&#8211; <strong>Messaging Spam Protection<\/strong> \u2013 Implement cooldowns to avoid players flooding the chat.<br \/>\n&#8211; <strong>Contacts Import<\/strong> \u2013 Allow players to import contacts from a shared database for easier management.  <\/p>\n<p>Each of these enhancements can be tackled later, but by starting with the hash fix you\u2019ll eliminate a major friction point for your players.  <\/p>\n<p>&#8212;<\/p>\n<h2>Conclusion  <\/h2>\n<p>The <strong>CrewPhone hash problem<\/strong> is a minor glitch that can feel like a major roadblock. By ensuring the client fires the `crew:onPlayerLoaded` event right after a player\u2019s loadout is restored, you signal the server to link the correct phone number, eliminating the placeholder `###-####` display. Implement the snippet above, test it, and you\u2019ll have a seamless phone experience for your players.  <\/p>\n<p>Quick recap:  <\/p>\n<p>1. <strong>Insert the event trigger<\/strong> at the top of your client file.<br \/>\n2. <strong>Patch the `esx:restoreLoadout` handler<\/strong> with the detailed code example.<br \/>\n3. <strong>Restart the server<\/strong> and verify the number shows correctly.  <\/p>\n<p>With these steps, the CrewPhone hash problem will be a memory of the past, allowing your community to enjoy a fully functional in\u2011game telephone system. Happy gaming!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Com dificuldades para gerar n\u00fameros no CrewPhone? Um ajuste r\u00e1pido no es_extended client.lua far\u00e1 com que seus n\u00fameros sejam exibidos corretamente em segundos!<\/p>","protected":false},"author":1,"featured_media":1309,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1900],"tags":[],"class_list":["post-9904","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-troubleshooting"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/fivemx.com\/pt\/wp-json\/wp\/v2\/posts\/9904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemx.com\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemx.com\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemx.com\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemx.com\/pt\/wp-json\/wp\/v2\/comments?post=9904"}],"version-history":[{"count":0,"href":"https:\/\/fivemx.com\/pt\/wp-json\/wp\/v2\/posts\/9904\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemx.com\/pt\/wp-json\/wp\/v2\/media\/1309"}],"wp:attachment":[{"href":"https:\/\/fivemx.com\/pt\/wp-json\/wp\/v2\/media?parent=9904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemx.com\/pt\/wp-json\/wp\/v2\/categories?post=9904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemx.com\/pt\/wp-json\/wp\/v2\/tags?post=9904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}