Riddy Posted March 3, 2013 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
Riddy Posted March 3, 2013 Author Posted March 3, 2013 It says Attempt to call global 'addCommandHandler' (a nil value)
Cassandra Posted March 3, 2013 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.
Anderl Posted March 3, 2013 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.
Riddy Posted March 3, 2013 Author 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
PaiN^ Posted March 4, 2013 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 )
Anderl Posted March 4, 2013 Posted March 4, 2013 @Razor., your code does not make sense. @Riddy, check my reply above.
Sasu Posted March 5, 2013 Posted March 5, 2013 Do you want that the command create a vehicle to a target?
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