SQL Query from LUA

04/26/2015 19:12 thund22222#1
I have worked with the idea of @mongreldogg but i have a problem does not describe the thread guide
if you want to modify, for example, in-game gold, just type the command mssql_query ("update Character set gold = 100 where account = test") but if you want to link to the tool through the function how do I bring the player's account name in lua
i have many experiences in lua script for example
account_name = gv("account")
mssql_query ("update Character set gold = 100 where account = "..account_name)
The result is a server crash

anyhelp how can i do it?
05/03/2015 16:37 DARK-REVO#2
hmm try this
05/03/2015 19:59 thund22222#3
Quote:
Originally Posted by DARK-REVO View Post
hmm try this
ok this code will be executed
mssql_query("UPDATE [dbo].[SQLLUA] SET [winners] =0
but , this ?!! How the server will bring a player name?
WHERE 1=1
05/03/2015 22:24 TheSuperKiller#4
you have global flags and its procedures you can make magic with it, just think from another perspective, for example ( if in_key like blah blah exec blah blah that contains where "in_value" )

Mongreldogg gave you amazing idea just use logic to modify it as you want, not using it as it is .
05/04/2015 19:09 thund22222#5
Quote:
Originally Posted by TheSuperKiller View Post
you have global flags and its procedures you can make magic with it, just think from another perspective, for example ( if in_key like blah blah exec blah blah that contains where "in_value" )

Mongreldogg gave you amazing idea just use logic to modify it as you want, not using it as it is .
hmm ok
but how can the server bring the account name by using the tool?
Where "in_value"-a – > This means the variable I will enter into the mssql
function
05/04/2015 23:31 TheSuperKiller#6
Quote:
Originally Posted by thund22222 View Post
hmm ok
but how can the server bring the account name by using the tool?
Where "in_value"-a – > This means the variable I will enter into the mssql
function
think outside the box ... edit the procedure itself.

if in_key like '%_bringusername'
exec blah blah where in_value 'his name'

and all that blah blah is the sql query which will do everything from his name .

it's all about minds and proper logic use .
05/05/2015 00:23 thund22222#7
you cannot do this because the server can not bring a player's account name
you can apply what you said, but you must enter the account name the player manually
in this case would be 500 + Player how you can enter in a short time?
I'll explain you ---->the example I'm going to change the value of the gold via the sql command look at this
update Character set gold = 50 where account_id = 1 ---> this will change all the values in all the characters that have account id 1 ,but if you want to bring the account id of the account that automatically use, value must be the account id = variable
like this in lua script
account_id=gv("account_id")
update Character set gold = 50 where account_id = .. account_id .. ---> now the value of account id variable depending on use
but in sql with lua ?? how can doit? like smp account there is a variable name @IN_ACCOUNT_ID this variable is the value automatically
if this variable is really in smp global variables was solved the problem !!
05/05/2015 00:51 ThunderNikk#8
This line brings the player name into the script...

function on_login( name )

All I had to add into on_login.lua to get it to announce my player had logged in is the following

private_notice("".. name .." Has Logged In.")

So now you see it is very easy for lua to pull different variables from the account like character name.

You can probably do the same thing with a function...

function set_gold_ammount (account)

See normally a function contains empty variables like...

function set_gold_ammount ()

Until you define what the variable should be

That's what DARK-REVO was trying to say with this...

function Revo_Lution_Team(name_player)
notice("the winner is .. ,<#ff0000>[ ".. name_player .." ]")
add_state(320006,1,1080000,"".. name_player .."")

mssql_query("UPDATE [dbo].[SQLLUA] SET [winners] =0 WHERE 1=1") -- 0
end

The (name_player) defined the function, I just know mine works with just (name)
05/05/2015 02:17 TheSuperKiller#9
Quote:
Originally Posted by thund22222 View Post
you cannot do this because the server can not bring a player's account name
you can apply what you said, but you must enter the account name the player manually
in this case would be 500 + Player how you can enter in a short time?
I'll explain you ---->the example I'm going to change the value of the gold via the sql command look at this
update Character set gold = 50 where account_id = 1 ---> this will change all the values in all the characters that have account id 1 ,but if you want to bring the account id of the account that automatically use, value must be the account id = variable
like this in lua script
account_id=gv("account_id")
update Character set gold = 50 where account_id = .. account_id .. ---> now the value of account id variable depending on use
but in sql with lua ?? how can doit? like smp account there is a variable name @IN_ACCOUNT_ID this variable is the value automatically
if this variable is really in smp global variables was solved the problem !!

you will never understand what is critical thinking.
you want a ready piece of cake to eat, just like anyone else here in this forum who don't use their minds, so take it :


global flag insert smp :
Code:
if @IN_KEY like '%_change_fucking_gold'
begin
exec ('update telecatser.dbo.Character set gold = 50 where account_id in (select account_id from Character where name = N''' + @IN_VALUE + '''' )
end
lua:
Code:
function change_fucking_gold_using_logic()
name = gv("name")
if get_global_variable("queries_count") == "" then
set_global_variable("queries_count", 0)
end
set_global_variable("queries_count", get_global_variable("queries_count") + 1)
set_global_variable(get_global_variable("queries_count") .. "_change_fucking_gold", name)
end

edit 1 :you can workout this and make another stored procedure to do the stuff in the executing command, but I think it will make brain overload that's why I gave you what you really familiar with like any fake *devs* around here so that you can use your imagination well.
edit 2 : you can rewrite what is included above and make a more efficient script that satisfies all your needs.
05/05/2015 16:06 thund22222#10
Quote:
Originally Posted by TheSuperKiller View Post
you will never understand what is critical thinking.
you want a ready piece of cake to eat, just like anyone else here in this forum who don't use their minds, so take it :


global flag insert smp :
Code:
if @IN_KEY like '%_change_fucking_gold'
begin
exec ('update telecatser.dbo.Character set gold = 50 where account_id in (select account_id from Character where name = N''' + @IN_VALUE + '''' )
end
lua:
Code:
function change_fucking_gold_using_logic()
name = gv("name")
if get_global_variable("queries_count") == "" then
set_global_variable("queries_count", 0)
end
set_global_variable("queries_count", get_global_variable("queries_count") + 1)
set_global_variable(get_global_variable("queries_count") .. "_change_fucking_gold", name)
end

edit 1 :you can workout this and make another stored procedure to do the stuff in the executing command, but I think it will make brain overload that's why I gave you what you really familiar with like any fake *devs* around here so that you can use your imagination well.
edit 2 : you can rewrite what is included above and make a more efficient script that satisfies all your needs.
At the outset, I would like to tell you thanks for the try but sorry if what I wrote the server will crash
it seems that the cake wasn't ready


Seems my friend you have in your collection, which I have labelled (mind out of coverage)Try again to speak with others in a respectful

Note:I put this problem after tests failed
05/06/2015 00:41 TheSuperKiller#11
Quote:
Originally Posted by thund22222 View Post
At the outset, I would like to tell you thanks for the try but sorry if what I wrote the server will crash
it seems that the cake wasn't ready


Seems my friend you have in your collection, which I have labelled (mind out of coverage)Try again to speak with others in a respectful

Note:I put this problem after tests failed
the query itself causes crash if executed by itself , I gave you the solution approach not the problem analysis.
05/06/2015 06:23 thund22222#12
Anyway thank you for trying to help me