Script Help

smoochy boys on tour

mirlin6

Golden Oldie
Golden Oldie
Aug 11, 2004
532
3
124
United Kingdom
I am making a script atm but i want to read something out of sql a username and then the script check it and it is ready for the next part
could anyone show me how this is done please im still a little unsure how sql works :S
 
  • Like
Reactions: darkkiller

mapadale

Guest
I am making a script atm but i want to read something out of sql a username and then the script check it and it is ready for the next part
could anyone show me how this is done please im still a little unsure how sql works :S
<$USERNAME>
 
Upvote 0

mirlin6

Golden Oldie
Golden Oldie
Aug 11, 2004
532
3
124
United Kingdom
Nope still doesent work i cant find the right comand to read sql and then check if the username is there :(

Heres what i have

[@Main]
#SAY
Hey {FCOLOR/2}<$USERNAME>{FCOLOR/0},
\
Have you voted? if you have you\
will be eligible for a reward\

< [Check for reward]/@Check>\

[@check]
#SAY
Please Wait a Second....\
#ACT
got @checking


[@checking]
#ACT
FormatStr "FLD_USERNAME='%s'" %USERNAME
ReadValueSql "TBL_VOTE" %A9 "FLD_USERNAME" - i want it to check if the username exist in the database and then goto the next stage

[@next1]
#SAY
We have found your Username!\
\
<[ Collect Junes Reward]/@Reward>\
\
#ELSESAY
Sorry we did not find your\
username!\
 
Last edited:
Upvote 0

chimera

LOMCN VIP
VIP
Jul 30, 2003
1,054
23
235
UK
Nope still doesent work i cant find the right comand to read sql and then check if the username is there :(

Heres what i have

[@Main]
#SAY
Hey {FCOLOR/2}<$USERNAME>{FCOLOR/0},
\
Have you voted? if you have you\
will be eligible for a reward\

< [Check for reward]/@Check>\

[@check]
#SAY
Please Wait a Second....\
#ACT
goto @checking


[@checking]
#ACT
FormatStr "FLD_USERNAME='%s'" %USERNAME
ReadValueSql "TBL_VOTE" %A9 "FLD_USERNAME" - i want it to check if the username exist in the database and then goto the next stage

This is just looking on tbl_vote for the username but I suggest you have a 3rd column being a yes/no column or add a column to the character table and interrogate that instead to see if the answer is yes/no 1/0 (whatever you choose to use).

What I would do - add a column to character_tbl called voted, values being 1 (voted) or 0 (not voted) and then

#ACT
FormatStr "FLD_USERNAME='%s'" %USERNAME
ReadValueSql "TBL_VOTE" %A9 "fld_voted" @votecheck

[@votecheck()]
#act
mov D1 %arg(1)

this will make the value in D1 = 0 or 1 which you can interrogate and use for the rest of the script.


[@next1]
#SAY
We have found your Username!\
\
<[ Collect Junes Reward]/@Reward>\
\
#ELSESAY
Sorry we did not find your\
username!\


Hope this helps :)
 
Upvote 0

chimera

LOMCN VIP
VIP
Jul 30, 2003
1,054
23
235
UK
this will make the value in D1 = 0 or 1 which you can interrogate and use for the rest of the script.

so in other words you would do:

#IF
Equal D1 1
#SAY
We have found your Username!\\
<[ Collect Junes Reward]/@Reward>\\
#ELSESAY
Sorry we did not find your\\
username!\\
 
Upvote 0

Amenovis

Golden Oldie
Golden Oldie
Loyal Member
Jan 9, 2006
1,105
0
143
Germany
mhh i only ask me why never the ppl use flags ?? works same way and much easier

#if
something has done
#act
set [XXX] 0 or 1

and the other side check [XXX] 1

means


[@main]
#if
check [400] 1
#say
u had voted
#elsesay
Do u wanna vote?
<Yes/@flag1>\
<No/@flag2>\
<Exit/@exit>

[flag1]
#act
set [400] 1
#say
u have voted now!\
<Take/@take1> ur reward.

[@flag2]
#say
ok than maybe later\
<exit/@exit>

[@take1]
#act
give xyz
#say
good luck with it \
<exit/@exit>


or did i understand wrong what he wanna do ?
 
Upvote 0

mirlin6

Golden Oldie
Golden Oldie
Aug 11, 2004
532
3
124
United Kingdom
what i want to do is reward people who vote for the server by doing this via the database i can add there name an they can get there reward each month.
 
Upvote 0

chimera

LOMCN VIP
VIP
Jul 30, 2003
1,054
23
235
UK
It's possile with flags but it's a one-shot deal, with sql it's easier to change an entry and simpler to understand a script, imo :)
 
Upvote 0

mirlin6

Golden Oldie
Golden Oldie
Aug 11, 2004
532
3
124
United Kingdom
Is there a way i can add a number to sql through a script chim?

so like verytime someone press it will add + 1 in the database and there will be 2 columbs like Yes \ No (example)
 
Last edited:
Upvote 0

chimera

LOMCN VIP
VIP
Jul 30, 2003
1,054
23
235
UK
yup you read the accumulator column and call it a D number as above, then

inc D? 1

then

format your string with the same D number which has now increased by 1

followed by an
#act
updatevaluesql tbl_.... fld_.... string

not sure why you'd need 2 columns saying y/n...
 
Upvote 0

mirlin6

Golden Oldie
Golden Oldie
Aug 11, 2004
532
3
124
United Kingdom
[@test1]
#ACT
INC D1 1
goto @test2

[@test2]
#ACT
UPDATEVALUESQL "TBL_VOTEHOST" "FLD_YES" %D1
goto @voteh

Like that? i tested but doesent seem to work :S
 
Upvote 0

chimera

LOMCN VIP
VIP
Jul 30, 2003
1,054
23
235
UK
you forgot to format string....assuming your column you are storing number in is fld_yes...

#act
FormatStr "FLD_NAME='%s'" %USERNAME
MOV A1 %A9
FormatStr "FLD_YES='%s'" %D1
MOV A2 %A9
UPDATEVALUESQL "TBL_VOTEHOST" %A1 %A2


That looks in TBL_VOTED for the line that matches the username and makes the FLD_YES the new number.
 
Upvote 0

mirlin6

Golden Oldie
Golden Oldie
Aug 11, 2004
532
3
124
United Kingdom
still doesent work for some reason :S heres my script on the script it adds +1 but not in sql theres nothing

[@voteh]
#IF
Check [401] 0
#SAY
Hello <$USERNAME>,\
I hold votes for the server\
\
Should i add more mob?\ - thats just an example
\
Yes: {FCOLOR/1}<$OUTPUT(D1)>{FCOLOR/12}\
\
No: {FCOLOR/1}<$OUTPUT(D2)>{FCOLOR/12}\
\
<[ Yes]/@Yes>\
\
<[ No]/@No>\
\
#IF
Check [401] 1
#SAY
You already voted\
\
Should i add more mobs?\
\
Yes: {FCOLOR/1}<$OUTPUT(D1)>{FCOLOR/12}\
\
No: {FCOLOR/1}<$OUTPUT(D2)>{FCOLOR/12}\
\

[@Yes]
#ACT
INC D1 1
SET [401] 1
FormatStr "FLD_USERNAME='%s'" %USERNAME
Mov A8 %A9
FormatStr "FLD_YES='%s'" %D1
MOV A2 %A9
UPDATEVALUESQL "TBL_VOTEHOST" %A8 %A9
goto @voteh

[@No]
#ACT
INC D2 1
SET [401] 1
FormatStr "FLD_USERNAME='%s'" %USERNAME
MOV A1 %A9
FormatStr "FLD_NO='%s'" %D2
MOV A2 %A9
UPDATEVALUESQL "TBL_VOTEHOST" %A1 %A2
goto @voteh
 
Upvote 0

chimera

LOMCN VIP
VIP
Jul 30, 2003
1,054
23
235
UK
still doesent work for some reason :S heres my script on the script it adds +1 but not in sql theres nothing

[@voteh]
#IF
Check [401] 0
#SAY
Hello <$USERNAME>,\
I hold votes for the server\
\
Should i add more mob?\ - thats just an example
\
Yes: {FCOLOR/1}<$OUTPUT(D1)>{FCOLOR/12}\
\
No: {FCOLOR/1}<$OUTPUT(D2)>{FCOLOR/12}\
\
<[ Yes]/@Yes>\
\
<[ No]/@No>\
\
#ELSESAY
You already voted\
\
Should i add more mobs?\
\
Yes: {FCOLOR/1}<$OUTPUT(D1)>{FCOLOR/12}\
\
No: {FCOLOR/1}<$OUTPUT(D2)>{FCOLOR/12}\
\

[@Yes]
#ACT
INC D1 1
SET [401] 1
FormatStr "FLD_USERNAME='%s'" %USERNAME
Mov A8 %A9
FormatStr "FLD_YES='%s'" %D1
MOV A2 %A9
UPDATEVALUESQL "TBL_VOTEHOST" %A8 %A2
goto @voteh

[@No]
#ACT
INC D2 1
SET [401] 1
FormatStr "FLD_USERNAME='%s'" %USERNAME
MOV A1 %A9
FormatStr "FLD_NO='%s'" %D2
MOV A2 %A9
UPDATEVALUESQL "TBL_VOTEHOST" %A1 %A2
goto @voteh


see above for changes...
The way you've had it set up people could vote for oth yes and no.
 
Upvote 0