Jump to content
Sign in to follow this  
Cr4sh

Is it possible to use &lua Command for give player an item

Recommended Posts

Hello ,I've tried to give player item using &lua cmd , but it doesn't  give it

It says lua_GiveItem Parameter Error and so on.

while i've set up 3 parameters(id,quantity,quality) it still show the error

 

is it possible to do that anyway?

Thanks in advance!

Share this post


Link to post
Share on other sites

Problem is getting role. Set up a function to save players role to a table (eg PlayerRole[GetRoleID(role)] = role ) , then use that table to execute command as the role parameter

Share this post


Link to post
Share on other sites

GiveItem has 5 parameters to be exact

 

GiveItem(role, 0, itemid, quantity, quality)

 

function GiveItem2Player(characterName, id, quantity, quality)
	local role = PlayerRole[characterName]
	GiveItem(role, 0, id, quantity, quality);
end

 

Further more you need to add a couple lines in cha_timer to save the role

 

Above function cha_timer(role,freq,time) add

PlayerRole = { }

 

 

 

if(IsPlayer(role) == 1) then
  PlayerRole[GetChaDefaultName(role)] = role;
end
  

 

This is only one of many simple ways to go about this.

Share this post


Link to post
Share on other sites

@Xeon Using IsPlayer(role) == 1 doesnt stop boats being used, and GetChaDefaultName on a boat gives the boats name, not the players name. That could be abused to trick the admin into spawning items for the wrong player. You should also do a check if the player is a boat to prevent this.

Edited by 7n6

Share this post


Link to post
Share on other sites

The use of IsPlayer, was not meant for this @7n6It was only meant for not getting monsters & npcs into the list, fyi this was just a quick draft of a script, nothing more before. Before criticizing why not try to help I was refering to his question nothing more, and if an "admin" is tricked when giving items to a player, when they are the one executing the command in the first place isnt likely. He was only asking about a parameter error nothing more.

Share this post


Link to post
Share on other sites

He does make a good point jay ^^
But, simple fix: 


local cha = TurnToCha(role)
if(IsPlayer(cha) == 1) then

PlayerRole[GetChaDefaultName(cha)] = cha;

end

 

But i guess things like this belongs within the src codes itself. Maybe you can do that jay. 


kong.png

a2.png

Share this post


Link to post
Share on other sites

I have GameServer.exe with GetChaByName() function. I will release it soon or show how to add the function to GameServer.exe

 

local cha, online = GetChaByName("Cr4sh")

if (online == true) then
	Notice("Character Cr4sh is online! Let's give to him an item!")
	GiveItem(cha, 0, id, quantity, quality)
else
	Notice("Character Cr4sh is offline or on another GameServer.exe! ")
end

 

Topic is moved to 'Questions & Help' section.


Share this post


Link to post
Share on other sites

And i also meant like when uu hacking a server or smth(example)

and u want to give ur self item  by using &lua GiveItem

 

how can i do that

 

Share this post


Link to post
Share on other sites

Could some1 tell me how to implement those functions step by step?

I'm confused..

I'm already using [BS HandleChat & GetGmLev & Party Search Fix] GameServer.exe

Thanks in advance  :)

Edited by GummyBear

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...