Talkactions!
Ok, for this function I'm going to, just like the action one, make step by step a nice, working sript.
Action means, if a player uses something... something will happen.
Talkactions means: if a player says something... something will happen.
What shall we make this time??? Hmmm.....
[think]...[/think] I got it!
What about a script, if you say something, you'll get an item, and money from your backpack will be removed.
But which item??? Hmmm.....
[think]...[/think] An amulet of loss! People use it many times, so this command will make it faster for them to get one.
Ok here we go...!
The beginning:
In order to get the aol, the player has to give money. To do that, we use this command:
-doPlayerRemoveMoney(cid,count)
We have to change this command a bit, so the player has to give 15k, or: 15.000 gold, so:
(NOTE THAT YOU CAN'T PUT 15K INSTEAD OF 15000! ALWAYS IN GOLD COINS!)
Did you see I put if before the command? It just says, if the player gives 15000 gp... then something will happen.
Also, I put == TRUE after the command. That is so the server checks if it's true which means, if the player really gives money... if I put FALSE, then the player can get as many aols as he want, because they're for free then
Then, we want the player to get an amulet of loss.. the itemID if an aol is 2173. To give the player an item, use this command:
-doPlayerAddItem(cid,itemid,count or type)
Now we have to change the command a bit before we add it to our script. The itemid is 2173, and the count? Only 1 right.. so:
-doPlayerAddItem(cid,2173,1)
In our script:
Now we can end the script by placing an "end" at the end, but this one would be really boring. Why won't we send a text to the player, a magic effect and put a cancel if the player doesn't have enough money? That would me more awesome.
To send a magic effect, you'll need this command:
-doSendMagicEffect(position,type)
Now we get to something new. Where it says position, we have to put the player's position. But were not going to place like 1000000 coordinates... We have a special command for that:
-getPlayerPosition(cid)
With this command, it doesn't matter where the player is standing, it'll always work. So we have to put this command into the other, where it says position:
-doSendMagicEffect(getPlayerPosition(cid),type)
Now there is one thing left, the type. ALL the types can be found in global.lua. Let's take type 12 (uh type). So it's going to be:
-doSendMagicEffect(getPlayerPosition(cid),12)
Now there are two things left: the text, and the cancel. We'll begin with the text. To send the player a text, use this command:
-doPlayerSendTextMessage(cid,MessageClasses,message )
Where it says MessageClasses, we have to put a number. I looked into global.lua, and I saw number 22. That will do the job.
And ofcourse, the message: "You've bought an Amulet of Loss!"
So it's going to be:
-doPlayerSendTextMessage(cid,22,"You've bought an Amulet of Loss!")
In our script:
Now for the last thing: if the player doesn't have the money, we send him a cancel with this command:
-doPlayerSendCancel(cid,text)
Let's put in text: "You don't have enough money."
So:
-doPlayerSendCancel(cid,"You don't have enough money.")
I just thought, why not send also a magic-effect if the player gets a cancel? You know that kinda white flash...? It's magiceffect is 2, so:
-doSendMagicEffect(getPlayerPosition(cid),2)
In our script:
Now did you notice that else? It means, if the player doesn't have the requirements which are shown in the beginning of the script, he gets a cancel-message. In scripting language: else, doPlayerSendCancel(...)
Don't forget to put "end" at the end of every if! This is our final script:
You can do everything with talkactions. Like, say something on a special tile, and you get teleported to another place. Or, you say something, and a wall will be removed.
It's quite fun
Code:
[COLOR=#333333]function onSay(cid, words, param)[/COLOR]
Ok, for this function I'm going to, just like the action one, make step by step a nice, working sript.
Action means, if a player uses something... something will happen.
Talkactions means: if a player says something... something will happen.
What shall we make this time??? Hmmm.....
[think]...[/think] I got it!
What about a script, if you say something, you'll get an item, and money from your backpack will be removed.
But which item??? Hmmm.....
[think]...[/think] An amulet of loss! People use it many times, so this command will make it faster for them to get one.
Ok here we go...!
The beginning:
Code:
[COLOR=#333333]function onSay(cid, words, param)[/COLOR]
-doPlayerRemoveMoney(cid,count)
We have to change this command a bit, so the player has to give 15k, or: 15.000 gold, so:
(NOTE THAT YOU CAN'T PUT 15K INSTEAD OF 15000! ALWAYS IN GOLD COINS!)
Code:
[COLOR=#B1B100]function[/COLOR][COLOR=#333333] onSay[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]cid, words, param[/COLOR][COLOR=#66CC66])[/COLOR]
[COLOR=#B1B100]if[/COLOR][COLOR=#333333] doPlayerRemoveMoney[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]cid,[/COLOR][COLOR=#CC66CC]15000[/COLOR][COLOR=#66CC66])[/COLOR][COLOR=#66CC66]==[/COLOR][COLOR=#333333] TRUE [/COLOR][COLOR=#B1B100]then[/COLOR]
Also, I put == TRUE after the command. That is so the server checks if it's true which means, if the player really gives money... if I put FALSE, then the player can get as many aols as he want, because they're for free then
Then, we want the player to get an amulet of loss.. the itemID if an aol is 2173. To give the player an item, use this command:
-doPlayerAddItem(cid,itemid,count or type)
Now we have to change the command a bit before we add it to our script. The itemid is 2173, and the count? Only 1 right.. so:
-doPlayerAddItem(cid,2173,1)
In our script:
Code:
[COLOR=#B1B100]function[/COLOR][COLOR=#333333] onSay[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]cid, words, param[/COLOR][COLOR=#66CC66])[/COLOR]
[COLOR=#B1B100]if[/COLOR] doPlayerRemoveMoney[COLOR=#66CC66]([/COLOR]cid,[COLOR=#CC66CC]15000[/COLOR][COLOR=#66CC66])[/COLOR] [COLOR=#66CC66]==[/COLOR] [COLOR=#CC66CC]1[/COLOR] [COLOR=#B1B100]then
[/COLOR][COLOR=#333333] doPlayerAddItem[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]cid,[/COLOR][COLOR=#CC66CC]2173[/COLOR][COLOR=#333333],[/COLOR][COLOR=#CC66CC]1[/COLOR][COLOR=#66CC66])[/COLOR]
To send a magic effect, you'll need this command:
-doSendMagicEffect(position,type)
Now we get to something new. Where it says position, we have to put the player's position. But were not going to place like 1000000 coordinates... We have a special command for that:
-getPlayerPosition(cid)
With this command, it doesn't matter where the player is standing, it'll always work. So we have to put this command into the other, where it says position:
-doSendMagicEffect(getPlayerPosition(cid),type)
Now there is one thing left, the type. ALL the types can be found in global.lua. Let's take type 12 (uh type). So it's going to be:
-doSendMagicEffect(getPlayerPosition(cid),12)
Code:
[COLOR=#B1B100]function[/COLOR][COLOR=#333333] onSay[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]cid, words, param[/COLOR][COLOR=#66CC66])[/COLOR]
[COLOR=#B1B100]if[/COLOR] doPlayerRemoveMoney[COLOR=#66CC66]([/COLOR]cid,[COLOR=#CC66CC]15000[/COLOR][COLOR=#66CC66])[/COLOR] [COLOR=#66CC66]==[/COLOR] [COLOR=#CC66CC]1[/COLOR] [COLOR=#B1B100]then[/COLOR]
doPlayerAddItem[COLOR=#66CC66]([/COLOR]cid,[COLOR=#CC66CC]2173[/COLOR],[COLOR=#CC66CC]1[/COLOR][COLOR=#66CC66])
[/COLOR][COLOR=#333333] doSendMagicEffect[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]getPlayerPosition[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]cid[/COLOR][COLOR=#66CC66])[/COLOR][COLOR=#333333],[/COLOR][COLOR=#CC66CC]12[/COLOR][COLOR=#66CC66])[/COLOR]
Now there are two things left: the text, and the cancel. We'll begin with the text. To send the player a text, use this command:
-doPlayerSendTextMessage(cid,MessageClasses,message )
Where it says MessageClasses, we have to put a number. I looked into global.lua, and I saw number 22. That will do the job.
And ofcourse, the message: "You've bought an Amulet of Loss!"
So it's going to be:
-doPlayerSendTextMessage(cid,22,"You've bought an Amulet of Loss!")
In our script:
Code:
[COLOR=#B1B100]function[/COLOR][COLOR=#333333] onSay[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]cid, words, param[/COLOR][COLOR=#66CC66])[/COLOR]
[COLOR=#B1B100]if[/COLOR] doPlayerRemoveMoney[COLOR=#66CC66]([/COLOR]cid,[COLOR=#CC66CC]15000[/COLOR][COLOR=#66CC66])[/COLOR] [COLOR=#66CC66]==[/COLOR] [COLOR=#CC66CC]1[/COLOR] [COLOR=#B1B100]then[/COLOR]
doPlayerAddItem[COLOR=#66CC66]([/COLOR]cid,[COLOR=#CC66CC]2173[/COLOR],[COLOR=#CC66CC]1[/COLOR][COLOR=#66CC66])[/COLOR]
doSendMagicEffect[COLOR=#66CC66]([/COLOR]getPlayerPosition[COLOR=#66CC66]([/COLOR]cid[COLOR=#66CC66])[/COLOR],[COLOR=#CC66CC]12[/COLOR][COLOR=#66CC66])
[/COLOR][COLOR=#333333] doPlayerSendTextMessage[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]cid,[/COLOR][COLOR=#CC66CC]22[/COLOR][COLOR=#333333],[/COLOR][COLOR=#FF0000]"You've bought an Amulet of Loss!"[/COLOR][COLOR=#66CC66])[/COLOR]
Now for the last thing: if the player doesn't have the money, we send him a cancel with this command:
-doPlayerSendCancel(cid,text)
Let's put in text: "You don't have enough money."
So:
-doPlayerSendCancel(cid,"You don't have enough money.")
I just thought, why not send also a magic-effect if the player gets a cancel? You know that kinda white flash...? It's magiceffect is 2, so:
-doSendMagicEffect(getPlayerPosition(cid),2)
In our script:
Code:
[COLOR=#B1B100]function[/COLOR][COLOR=#333333] onSay[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]cid, words, param[/COLOR][COLOR=#66CC66])[/COLOR]
[COLOR=#B1B100]if[/COLOR] doPlayerRemoveMoney[COLOR=#66CC66]([/COLOR]cid,[COLOR=#CC66CC]15000[/COLOR][COLOR=#66CC66])[/COLOR] [COLOR=#66CC66]==[/COLOR] [COLOR=#CC66CC]1[/COLOR] [COLOR=#B1B100]then[/COLOR]
doPlayerAddItem[COLOR=#66CC66]([/COLOR]cid,[COLOR=#CC66CC]2173[/COLOR],[COLOR=#CC66CC]1[/COLOR][COLOR=#66CC66])[/COLOR]
doSendMagicEffect[COLOR=#66CC66]([/COLOR]getPlayerPosition[COLOR=#66CC66]([/COLOR]cid[COLOR=#66CC66])[/COLOR],[COLOR=#CC66CC]12[/COLOR][COLOR=#66CC66])[/COLOR]
doPlayerSendTextMessage[COLOR=#66CC66]([/COLOR]cid,[COLOR=#CC66CC]22[/COLOR],[COLOR=#FF0000]"You've bought an Amulet of Loss!"[/COLOR][COLOR=#66CC66])
[/COLOR][COLOR=#B1B100]else[/COLOR] [COLOR=#808080][I]-- if the player doesn't have enough money...[/I][/COLOR]
doPlayerSendCancel[COLOR=#66CC66]([/COLOR]cid,[COLOR=#FF0000]"You don't have enough money."[/COLOR][COLOR=#66CC66])
[/COLOR][COLOR=#333333] doSendMagicEffect[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]getPlayerPosition[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]cid[/COLOR][COLOR=#66CC66])[/COLOR][COLOR=#333333],[/COLOR][COLOR=#CC66CC]2[/COLOR][COLOR=#66CC66])[/COLOR]
Now did you notice that else? It means, if the player doesn't have the requirements which are shown in the beginning of the script, he gets a cancel-message. In scripting language: else, doPlayerSendCancel(...)
Don't forget to put "end" at the end of every if! This is our final script:
Code:
[COLOR=#B1B100]function[/COLOR][COLOR=#333333] onSay[/COLOR][COLOR=#66CC66]([/COLOR][COLOR=#333333]cid, words, param[/COLOR][COLOR=#66CC66])[/COLOR]
[COLOR=#B1B100]if[/COLOR] doPlayerRemoveMoney[COLOR=#66CC66]([/COLOR]cid,[COLOR=#CC66CC]15000[/COLOR][COLOR=#66CC66])[/COLOR] [COLOR=#66CC66]==[/COLOR] [COLOR=#CC66CC]1[/COLOR] [COLOR=#B1B100]then[/COLOR]
doPlayerAddItem[COLOR=#66CC66]([/COLOR]cid,[COLOR=#CC66CC]2173[/COLOR],[COLOR=#CC66CC]1[/COLOR][COLOR=#66CC66])[/COLOR]
doSendMagicEffect[COLOR=#66CC66]([/COLOR]getPlayerPosition[COLOR=#66CC66]([/COLOR]cid[COLOR=#66CC66])[/COLOR],[COLOR=#CC66CC]12[/COLOR][COLOR=#66CC66])[/COLOR]
doPlayerSendTextMessage[COLOR=#66CC66]([/COLOR]cid,[COLOR=#CC66CC]22[/COLOR],[COLOR=#FF0000]"You've bought an Amulet of Loss!"[/COLOR][COLOR=#66CC66])
[/COLOR][COLOR=#B1B100]else[/COLOR]
doPlayerSendCancel[COLOR=#66CC66]([/COLOR]cid,[COLOR=#FF0000]"You don't have enough money."[/COLOR][COLOR=#66CC66])[/COLOR]
doSendMagicEffect[COLOR=#66CC66]([/COLOR]getPlayerPosition[COLOR=#66CC66]([/COLOR]cid[COLOR=#66CC66])[/COLOR],[COLOR=#CC66CC]2[/COLOR][COLOR=#66CC66])
[/COLOR]
[COLOR=#B1B100]end
[/COLOR][COLOR=#B1B100]return[/COLOR] TRUE
[COLOR=#B1B100]end[/COLOR]
You can do everything with talkactions. Like, say something on a special tile, and you get teleported to another place. Or, you say something, and a wall will be removed.
It's quite fun