Morelli Posted March 25, 2008 Share Posted March 25, 2008 Alright, I'm having some trouble getting this to work client-side. It doesn't seem to want to collect my information. -- Client-side. function TEST ( sourcePlayer, commandName ) local weapon_1 = getPlayerWeapon( sourcePlayer ) if ( weapon_1) then local check = outputChatBox ( "Weapon: " ..weapon_1 ) if ( not(check)) then outputChatBox ( "Didn't work. " ) end else outputChatBox("Not working...") end end addCommandHandler ( "t", TEST ) Don't mind all the if statements and making everything a local, I was trying to isolate the problem. It seems it is unable to pass the argument if ( weapon_1 ) then... This scripting function works perfectly fine server-side. I'm in need of this function to be working client-side so I can make a cycle to return all the player's weapons. Link to comment
Ace_Gambit Posted March 25, 2008 Share Posted March 25, 2008 The client-side addCommandHandler function as far as I know does not support a source parameter. This would mean that in your case sourcePlayer is actually the commandName and commandName a optional parameter. It wouldn't make any sense to pass a player as source to the client-side addCommandHandler function since this will always be the local player. But I could be wrong. Just try getLocalPlayer function as sourcePlayer and remove sourcePlayer as a function parameter. Link to comment
Morelli Posted March 26, 2008 Author Share Posted March 26, 2008 Ah, thanks for that. I'd been loosely basing my code on another client-side script that I had seen, which did include a source in the function name for a command. (Saw it at the client code example of Trigger Server Event) For those wishing to see a fixed code of this: function TEST ( commandName ) local weapon_1 = getPlayerWeapon( getLocalPlayer ( ) ) if ( weapon_1) then local check = outputChatBox ( "Weapon: " ..weapon_1 ) if ( not(check)) then outputChatBox ( "Didn't work. " ) end else outputChatBox("Not working...") end end addCommandHandler ( "t", TEST ) Seeing as this isn't a bug, we can sweep this thread into the corner and ignore it Link to comment
Recommended Posts