{"action":"created","issue":{"url":"https://api.github.com/repos/Facepunch/garrysmod-issues/issues/2325","labels_url":"https://api.github.com/repos/Facepunch/garrysmod-issues/issues/2325/labels{/name}","comments_url":"https://api.github.com/repos/Facepunch/garrysmod-issues/issues/2325/comments","events_url":"https://api.github.com/repos/Facepunch/garrysmod-issues/issues/2325/events","html_url":"https://github.com/Facepunch/garrysmod-issues/issues/2325","id":122573066,"number":2325,"title":"OnEntityCreated will pass null entity when a vehicle spawned (serverside only)","user":{"login":"ischmal","id":5350086,"avatar_url":"https://avatars.githubusercontent.com/u/5350086?v=3","gravatar_id":"","url":"https://api.github.com/users/ischmal","html_url":"https://github.com/ischmal","followers_url":"https://api.github.com/users/ischmal/followers","following_url":"https://api.github.com/users/ischmal/following{/other_user}","gists_url":"https://api.github.com/users/ischmal/gists{/gist_id}","starred_url":"https://api.github.com/users/ischmal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ischmal/subscriptions","organizations_url":"https://api.github.com/users/ischmal/orgs","repos_url":"https://api.github.com/users/ischmal/repos","events_url":"https://api.github.com/users/ischmal/events{/privacy}","received_events_url":"https://api.github.com/users/ischmal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-12-16T18:32:01Z","updated_at":"2015-12-17T23:26:50Z","closed_at":null,"body":"I have a Workshop addon that adds a variety of functionality to vehicles, after the December update it essentially stopped working entirely. I tracked down the culprit to the OnEntityCreated hook.\r\n\r\nOn the server, when the spawned entity is a vehicle, the entity fails IsValid( ent ) and a tostring( ent ) returns Vehicle [NULL].\r\n\r\nI created an OnEntityCreated hook that prints the entity then outputs the IsValid result. I also added a .5 second timer to do the same thing. Vehicles do the following:\r\n\r\n    Vehicle [NULL]\r\n    Valid spawned ent: false\r\n    After .5 seconds: Vehicle [14][prop_vehicle_jeep]\r\n\r\nWhich implies the entity becomes valid perhaps a tick after the hook is called. I only see this issue present with vehicle entities with the serverside hook. The clientside hook seems to work fine.\r\n\r\nI have patched my addon by adding a .1 second simple timer inside the hook, but I would not be surprised if other addons or code have been adversely affected by this.\r\n"},"comment":{"url":"https://api.github.com/repos/Facepunch/garrysmod-issues/issues/comments/165614393","html_url":"https://github.com/Facepunch/garrysmod-issues/issues/2325#issuecomment-165614393","issue_url":"https://api.github.com/repos/Facepunch/garrysmod-issues/issues/2325","id":165614393,"user":{"login":"robotboy655","id":3299036,"avatar_url":"https://avatars.githubusercontent.com/u/3299036?v=3","gravatar_id":"","url":"https://api.github.com/users/robotboy655","html_url":"https://github.com/robotboy655","followers_url":"https://api.github.com/users/robotboy655/followers","following_url":"https://api.github.com/users/robotboy655/following{/other_user}","gists_url":"https://api.github.com/users/robotboy655/gists{/gist_id}","starred_url":"https://api.github.com/users/robotboy655/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robotboy655/subscriptions","organizations_url":"https://api.github.com/users/robotboy655/orgs","repos_url":"https://api.github.com/users/robotboy655/repos","events_url":"https://api.github.com/users/robotboy655/events{/privacy}","received_events_url":"https://api.github.com/users/robotboy655/received_events","type":"User","site_admin":false},"created_at":"2015-12-17T23:26:49Z","updated_at":"2015-12-17T23:26:49Z","body":"In fact, all vehicle methods already have proper checks, so you can simply override Vehicle.IsValid to use Entity.IsValid for now and it should work fine."}}