• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

A help with a Lua Script

mikeware

New Member
Joined
Jul 17, 2007
Messages
338
Reaction score
0
Location
Brazil
Hey dudes

I know that there are not the right place to post this type of problem but in the LUA Forum they don't help a lot lol and my doubt is kinda simple i guess :)

I'll try to explain:
in the code above im trying to make the "localmonster" be like a word and a diferent number at the final, like monster12 or monster40, the number will be the player ID but I don't know how to do that, i tryed many things like:
Code:
localmonster = 'playersummon(getPlayerGUID(cid))'
or
Code:
localmonster = (playersummon(getPlayerGUID(cid)))
none of them works lol
here is the code
Code:
function onSay(cid, words, param)
localmonster = (playersummon(getPlayerGUID(cid)))[/
	doRemoveCreature(localmonster)
	localmonster = doSummonCreature("Rat", getPlayerPosition(cid))
	doConvinceCreature(cid, localmonster)
end
 
First of all: At the "lua forum", which is OpenLua. You didn't ask for help.
You spammed to get your 10 posts but you didn't ask for help.
So don't lie about us.

Second of all:
localmonster = (playersummon(getPlayerGUID(cid)))[/

Check the end.. Why are "[/" there?
 
First of all: At the "lua forum", which is OpenLua. You didn't ask for help.
You spammed to get your 10 posts but you didn't ask for help.
So don't lie about us.

Second of all:
localmonster = (playersummon(getPlayerGUID(cid)))[/

Check the end.. Why are "[/" there?


first of all, do you know how many posts I have? what about check it? and my join date? lol
second, i made many topics already in lua forum and none of them helped.

and the second part its just a word error, in the function there aren't this.
anyway thanks for reply.
 
Can you post the 'playersummon' function? I don't see anything wrong with the code that you posted except the characters that Super Kakan pointed out, but I can't see what the function playersummon looks like, so it's possible the problem is in there.
 
Can you post the 'playersummon' function? I don't see anything wrong with the code that you posted except the characters that Super Kakan pointed out, but I can't see what the function playersummon looks like, so it's possible the problem is in there.

the 'playersummon' is just a name, there is not a function :)

so in this line:
Code:
localmonster = doSummonCreature("Rat", getPlayerPosition(cid))
it would be like
Code:
playername14* = doSummonCreature("Rat", getPlayerPosition(cid))

*14 would be the player ID that used the skill(cid)

how do i make to make the localmonster be like 'a normal word like summon with a number at the final'... like, summon100?
 
local monster = {doSummonCreature("Rat", getPlayerPosition(cid)), doSummonCreature("Demon", getPlayerPosition(cid)), doSummonCreature("Skeleton", getPlayerPosition(cid)), doSummonCreature("Cave Rat", getPlayerPosition(cid)), doSummonCreature("Wasp", getPlayerPosition(cid)), doSummonCreature("Wolf", getPlayerPosition(cid)), doSummonCreature("Snake", getPlayerPosition(cid))}

Now you can access it like:
monster[1] is rat
monster[2] is demon
monster[3] is skeleton
...

You get the point I guess, but I'm not sure if this is what you want.
 
first of all, do you know how many posts I have? what about check it? and my join date? lol
second, i made many topics already in lua forum and none of them helped.

and the second part its just a word error, in the function there aren't this.
anyway thanks for reply.

You got 12 posts now.
Here's the most useless one of them:
good point :)

Here's the most useful one of them:
if he dies, the player will need to re-login to resummon the monster, must have another way to prevent this like a talkaction that summons if ur pet is dead, this can be checked with getcreaturehealth...

None of the posts contained a question.
And you haven't created any thread.
So, if you were to ask instead of complain you'd get help.

And I hope Talaturens reply helped ya.
Cause I don't get what you mean else.
 
local monster = {doSummonCreature("Rat", getPlayerPosition(cid)), doSummonCreature("Demon", getPlayerPosition(cid)), doSummonCreature("Skeleton", getPlayerPosition(cid)), doSummonCreature("Cave Rat", getPlayerPosition(cid)), doSummonCreature("Wasp", getPlayerPosition(cid)), doSummonCreature("Wolf", getPlayerPosition(cid)), doSummonCreature("Snake", getPlayerPosition(cid))}

Now you can access it like:
monster[1] is rat
monster[2] is demon
monster[3] is skeleton
...

You get the point I guess, but I'm not sure if this is what you want.

yes i got the point but the monster must be a diferent word for each player thats why im using getplayerGUID to get the id of them and add in the final of the monster word in this case.
would be like (following your example):
Code:
local [b]monster(getPlayerGUID(cid))[/b] = {doSummonCreature("Rat", getPlayerPosition(cid)), doSummonCreature("Demon", getPlayerPosition(cid)), doSummonCreature("Skeleton", getPlayerPosition(cid)), doSummonCreature("Cave Rat", getPlayerPosition(cid)), doSummonCreature("Wasp", getPlayerPosition(cid)), doSummonCreature("Wolf", getPlayerPosition(cid)), doSummonCreature("Snake", getPlayerPosition(cid))}
so if the player id of the one that uses the skill is 30 it would be like:
Code:
local monster30 = {doSummonCreature...



@Supar Kakan
you must be blind I guess lol, i have more than 200 messages and i joined in this forum in July, are you sure you are in the right forum? lol
 
Last edited:
You can set the creatures in an array with the position of players guid using this way:

monster[getPlayerGUID(cid)] = doSummonCreature(cid, "Rat")
debugPrint(getCreatureName(monster[getPlayerGUID(cid)])) -- this will debugPrint 'Rat'
 
You can set the creatures in an array with the position of players guid using this way:

monster[getPlayerGUID(cid)] = doSummonCreature(cid, "Rat")
debugPrint(getCreatureName(monster[getPlayerGUID(cid)])) -- this will debugPrint 'Rat'

Hmm I tryed your idea but i got this error:
data/talkactions/scripts/summon.lua:2: attempt to index global 'monster' (a nil value)
the code im testing:
Code:
function onSay(cid, words, param)
	monster[getPlayerGUID(cid)] = doSummonCreature("Rat", getPlayerPosition(cid))
	debugPrint(getCreatureName(monster[getPlayerGUID(cid)]))
	doConvinceCreature(cid, monster[getPlayerGUID(cid)])
end

it summon a rat but they are not convinced
 
Above:
monster[getPlayerGUID(cid)] = doSummonCreature("Rat", getPlayerPosition(cid))
Add:
local monster = {}
 
Trying to make a pet system in lua? :p

yes, something like that lol, but first i must make the basics works, then i can start making some options :)

@Talaturen
Ok I will test :)

edit:
I made an script to test the things:
Code:
local summonstorage = 3400

function onUse(cid, item, frompos, item2, topos)
local monster = {}

if getPlayerStorageValue(cid, summonstorage) == 1 then
	doRemoveCreature(monster[getPlayerGUID(cid)])
	setPlayerStorageValue(cid, summonstorage, -1)
else
	monster[getPlayerGUID(cid)] = doSummonCreature("Rat", getPlayerPosition(cid))
	doConvinceCreature(cid, monster[getPlayerGUID(cid)])
	setPlayerStorageValue(cid, summonstorage, 1)
end
end
they are not removing the creature after set the storage value to 1(it means the creature was summoned) and used the skill again..
there is the error:
Lua Script Error: [Action Interface]
data/actions/scripts/summoner teste.lua:eek:nUse

luaDoRemoveCreature(). Creature not found
 
Last edited:
That's because the monster variable is reset everytime you run that function.
 
If you're trying to create a pet system, how about creating a new table in your database called pets and giving them their unique pet id, and then in players table you can add a new field like "pet" which contains the pets id, if it's not 0 then it'll load pet data from the pets table.

This is a case where LuaSQL comes handy.
 
If you're trying to create a pet system, how about creating a new table in your database called pets and giving them their unique pet id, and then in players table you can add a new field like "pet" which contains the pets id, if it's not 0 then it'll load pet data from the pets table.

This is a case where LuaSQL comes handy.

Actualy im not trying YET make an pet system, just an skill that summon a monster and if you use the skill again it will remove the previous and summon a new one or you can only summon a new one when the first die, if you could help me with that I would be thankful :)

and the idea of the table for pets are a good one :) but for my first objetive I guess i'll not need do anything in the database
 
Back
Top