• 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!

TalkAction [JOKE] !joke

King Simon

Learning Lua
Joined
Jul 29, 2013
Messages
16
Reaction score
3
Hey Guys i recently started scripting and this is my second script so far. Basically when you say !joke it will send a joke.

Rep ++ if i helped :D

In talkactions.xml add this line

XML:
<talkaction words="!joke" event="script" value="Jokes.lua"/>


then add a new file in talkactions/scripts and name it Jokes.lua

inside add this code :
Lua:
local jokes = {
  "I swear to drunk I'm not God, but seriously, stay in drugs, eat school, and don't do vegetables.",
  "I named my hard drive 'dat ass' so once a month my computer asks if I want to 'back dat ass up'.",
  "If a guy remembers the color of your eyes after the first date, chances are... you have small boobs.",
  "Relationships are a lot like algebra. Have you ever looked at your X and wondered Y?",   
  "why do midgets laugh while running through the yard? The grass tickles their nuts",
  "I hate when I am about to hug someone really sexy and my face hits the mirror.",
  "If you force sex on a prostitute is it rape or shoplifting?",
  "Scooters are for men who want to ride motorcycles, but prefer to feel the wind on their vaginas.",
  "I was at a restaurant and I noticed my waitress had a black eye. So I ordered very sloooowly because obviously she doesn't listen.",
  "Every time someone calls me fat I get so depress I cut myself... a piece of cake.",
  "Dear Santa,I've been good all year. Okay most of the time. Once in awhile...F*ck it I'll buy my own shit.",
  "A big shout out to sidewalks... Thanks for keeping me off the streets.",
  "you're a boob. just tittin. you're my breast friend.",
  "Sex is not the answer. Sex is the question. 'Yes' is the answer.",
  "Never give up on your dreams. Keep sleeping.",
  "When I woke up today, I had no plans to be awesome but hey, shit happens.",
}
local i = #jokes  --- number of Jokes
function onSay(cid, words, param)
 doPlayerSendTextMessage(cid, 6, jokes[math.random(1,i)])
end

You can add ur own jokes in the lines


I also made this a globalevent for anyone who doesn't like the talkaction

in globalevents.xml add:
XML:
<globalevent name="Jokes" interval="1000" script="Jokes.lua"/>

change the interval to how often you want it to display.

then in globalevents/scripts add a new file called Jokes.lua

in this file add this code:
Lua:
local jokes = {
  "I swear to drunk I'm not God, but seriously, stay in drugs, eat school, and don't do vegetables.",
  "I named my hard drive 'dat ass' so once a month my computer asks if I want to 'back dat ass up'.",
  "If a guy remembers the color of your eyes after the first date, chances are... you have small boobs.",
  "Relationships are a lot like algebra. Have you ever looked at your X and wondered Y?",   
  "why do midgets laugh while running through the yard? The grass tickles their nuts",
  "I hate when I am about to hug someone really sexy and my face hits the mirror.",
  "If you force sex on a prostitute is it rape or shoplifting?",
  "Scooters are for men who want to ride motorcycles, but prefer to feel the wind on their vaginas.",
  "I was at a restaurant and I noticed my waitress had a black eye. So I ordered very sloooowly because obviously she doesn't listen.",
  "Every time someone calls me fat I get so depress I cut myself... a piece of cake.",
  "Dear Santa,I've been good all year. Okay most of the time. Once in awhile...F*ck it I'll buy my own shit.",
  "A big shout out to sidewalks... Thanks for keeping me off the streets.",
  "you're a boob. just tittin. you're my breast friend.",
  "Sex is not the answer. Sex is the question. 'Yes' is the answer.",
  "Never give up on your dreams. Keep sleeping.",
  "When I woke up today, I had no plans to be awesome but hey, shit happens.",
}
local i = #jokes  --- number of Jokes

function onThink(cid, interval, lastExecution)
    doBroadcastMessage("Joke: " .. jokes[math.random(1,i)],22)
    return TRUE
end

to add jokes just do the same thing as the talk action, and ur good to go :D

I tested this on tfs 0.3.6 and im not sure how any other distros work so if anyone has problems just post them here and hopefully someone can help you :)

Rep ++ if i helped :D
 
Last edited:
it can be made easier so you dont have to keep changing the value of i like so
Code:
local i = #jokes
 
ahh thanks :D
i will update it as soon as i figure out how :)

- - - Updated - - -

Ok original post was edited so you no longer have to change the i value
 
You can simply set this:
Lua:
function onSay(cid, words, param)
 doPlayerSendTextMessage(cid, 6, jokes[math.random(#jokes)])
end

Anyways, nice idea :)
 
You can simply set this:
Lua:
function onSay(cid, words, param)
 doPlayerSendTextMessage(cid, 6, jokes[math.random(#jokes)])
end

Anyways, nice idea :)

Haha thanks :D i appreciate you commenting as it improves my coding :)
 
Code:
doBroadcastMessage("Joke: " .. jokes[math.random(1,i)],[COLOR="#FF0000"]22[/COLOR])

Use Letters instead of 22

So it don't cause crash to some revs

- - - Updated - - -

can anyone change this script to a MOd script?

thnx..

Stop Being lazy it is just 2 files and 4 copy&paste..and you should be thankful to King Simon
 
Back
Top