Hello, i have been trying to make a mail system for my server, i have a few things..
okay, first, here is my script so far(it renderes without errors and creates the DB)
--Player mail system
function createSQLOnStart ()
-- create our table, if it doesn't already exist
executeSQLCreateTable ( "playermail", "playerto TEXT, mailmessage TEXT, mailsubject TEXT, mailread TEXT, mailfrom TEXT" )
end
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()),createSQLOnStart )
function sendMail (playerTo, title, message, from)
res = executeSQLInsert ( "playermail", "'" .. playerTo .. ",'" .. message .. "','" .. title .. "', '0', '" .. from .. "'" )
if ( res ) then
outputChatBox ("Mail Sent", source)
else
outputChatBox ("Failed to send mail", source)
end
end
addCommandHandler("sendmail", sendMail)
function checkmail ()
sourcename = getClientName ( source )
result = executeSQLSelect ( "playermail", "playerto", "mailmessage", "mailtitle", "mailread", "mailfrom", "playerto = '" .. sourcename .. "', mailread = '1'" )
if ( result == false ) then
outputChatBox ( "No new mail found", source )
else
outputChatBox ( "New Mail Found, Subject: " .. result[1][3] )
outputChatBox ( "Message: " .. result[1][2] )
outputChatBox ( "From: " .. result[1][5] )
executeSqlUpdate ( "playermail", "mailread = '1'", "playerto = '" .. sourcename .. "', mailsubject = '" .. result[1][3] .. "', mailmessage = '" .. result[1][2] .. "'" )
end
addCommandHandler("checkmail", checkmail)
end
Okay, so in-game "/sendmail" and "/checkmail" do nothing(not actually shore on sendmail because it has no output)
so i dunno why i does nothing.
Secondly, is there a way i can make it so only admins can send mail, and if this is possible, make it so the server can auto send mail(because cops can give out tickets, so i am also trying to work out how to make a ticket script force you to pay after 2 game days or jails you, i need help on where to start, i already have a jail script i can use)
so yea, got a few things i need help with, but mainly, i need it to work
thanks!
EDIT: may i ask what this means?
when i try to use sendmail, this happons in server console:
"Error: *pathtoscript*:266 attempting to concatenate global 'playerto' "
I am passing all required parameters (tried typing bizzycola and for my id '0' still getting nothing, also checkmail won't even say "no new mail" it also does nothing, but returns no errors
Edit2:
forgot 1 more thing, is there a way to tell if someone is putting out a fire?(for job script i am also making)
oh and also, anyone who solves my problems / answers my questions gets in the credits..(i am going to make a /credits or something)
and no, i am not asking you to write my scripts for me
Edit3:
if anyone knows how, i think the script would work better usig a text file,, but i don't know how to use text files with my script yet, oh and 1 other thing, when the script works, feel free to use it...credit would be nice, but not required...