Riddy Posted March 3, 2013 Share Posted March 3, 2013 function GivePlayerItem(player, item, amount) local playerID = GetPlayerFromName(player) if(playerID == true) then setElementData(playerID,item,amount) else outputChatbox("The name is invalid", player); end end addCommandHandler ( "createvehicle", GivePlayerItem ) Whats wrong? It gives me that, global thing mejic Link to comment
Riddy Posted March 3, 2013 Author Share Posted March 3, 2013 It says Attempt to call global 'addCommandHandler' (a nil value) Link to comment
Cassandra Posted March 3, 2013 Share Posted March 3, 2013 Your code didn't make any sense. function givePlayerItem(player, cmd, target, item, amount) local targetid = getPlayerFromName(target) or outputChatBox("Player not found", player) setElementData(targetid, "item." .. item, amount) end addCommandHandler ("giveitem", givePlayerItem) Check out the MTA Wiki. It helps. Link to comment
Anderl Posted March 3, 2013 Share Posted March 3, 2013 function GivePlayerItem(player, item, amount) local playerID = GetPlayerFromName(player) if(playerID == true) then setElementData(playerID,item,amount) else outputChatbox("The name is invalid", player); end end addCommandHandler ( "createvehicle", GivePlayerItem ) Whats wrong? It gives me that, global thing mejic 1. Lua is case-sensitive. 2. The command is named "createvehicle", but the code has completely nothing to do with vehicle creation. 3. Second parameter of the function handler when adding a command is the command name, not "item". 4. ruoY edoc ylpmis seod ton ekam yna esnes. Link to comment
Riddy Posted March 3, 2013 Author Share Posted March 3, 2013 Your code didn't make any sense. function givePlayerItem(player, cmd, target, item, amount) local targetid = getPlayerFromName(target) or outputChatBox("Player not found", player) setElementData(targetid, "item." .. item, amount) end addCommandHandler ("giveitem", givePlayerItem) Check out the MTA Wiki. It helps. I'll try that, thanks for the reply Link to comment
PaiN^ Posted March 4, 2013 Share Posted March 4, 2013 -- Server : function GivePlayerItem(player, item, amount) local playerID = getPlayerFromName(player) if( playerID == true ) then setElementData(playerID,"item",amount) else outputChatBox("The name is invalid", player, 255, 0, 0, true) end end addCommandHandler ( "giveitem", GivePlayerItem ) Link to comment
Anderl Posted March 4, 2013 Share Posted March 4, 2013 @Razor., your code does not make sense. @Riddy, check my reply above. Link to comment
Sasu Posted March 5, 2013 Share Posted March 5, 2013 Do you want that the command create a vehicle to a target? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now