Raised This Month: $51 Target: $400
 12% 

if connection to mysql failed, skip function


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-05-2019 , 09:51   if connection to mysql failed, skip function
Reply With Quote #1

Hey, how can I make this in plugin init

Code:
g_con = SQL_MakeDbTuple(DB_HOST, DB_USER, DB_PASS, DB_DB) 
db_con()
if connection fails, skip this and don't connect (because my database stopped working for a while and whole plugin was not working).

something like if (g_con == error).. skip db_con() ?

Last edited by TheBladerX; 02-05-2019 at 10:09.
TheBladerX is offline
Old 02-05-2019, 10:14
DjSoftero
This message has been deleted by DjSoftero. Reason: mistake
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 02-05-2019 , 10:21   Re: if connection to mysql failed, skip function
Reply With Quote #2

I got some questions for you. Do you want us to do everything for you? in that case, we need whole plugin, because if it doesn't connect, then you would have to add IF statements before every connection.
If you're asking for help in a sense of doing things yourself and just need some directions given, then read this: https://forums.alliedmods.net/showthread.php?t=132686 and if you got more questions left, feel free to ask.
DjSoftero is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-05-2019 , 10:23   Re: if connection to mysql failed, skip function
Reply With Quote #3

SQL_MakeDbTuple never fails and doesn't establish a connection either.
__________________
klippy is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-05-2019 , 10:47   Re: if connection to mysql failed, skip function
Reply With Quote #4

Okay, so what does? According to this code https://forums.alliedmods.net/showthread.php?t=307920
TheBladerX is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-05-2019 , 11:04   Re: if connection to mysql failed, skip function
Reply With Quote #5

It says exactly what it does in the doc: http://amxmodx.org/api/sqlx/SQL_MakeDbTuple
__________________
klippy is offline
TheBladerX
Member
Join Date: Dec 2012
Location: Slovakia
Old 02-05-2019 , 11:46   Re: if connection to mysql failed, skip function
Reply With Quote #6

Quote:
Originally Posted by KliPPy View Post
It says exactly what it does in the doc: http://amxmodx.org/api/sqlx/SQL_MakeDbTuple
Yeah, I meant, what does establish the connection.

Quote:
Originally Posted by DjSoftero View Post
I got some questions for you. Do you want us to do everything for you? in that case, we need whole plugin, because if it doesn't connect, then you would have to add IF statements before every connection.
If you're asking for help in a sense of doing things yourself and just need some directions given, then read this: https://forums.alliedmods.net/showthread.php?t=132686 and if you got more questions left, feel free to ask.
Sorry did not notice your post. That one did not work for me, after many tries. This one https://forums.alliedmods.net/showthread.php?t=307920 works perfectly. Let us say, that this is the code I would like to edit. I am familiar with that I need to use if statement, but I have no idea, how should the if statement look like. That is all I am asking for, thank you.

//edit:
this is what I was looking for
Code:
set_fail_state(g_Error)
Thank you.

Last edited by TheBladerX; 02-05-2019 at 11:55.
TheBladerX is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 02-05-2019 , 12:10   Re: if connection to mysql failed, skip function
Reply With Quote #7

set_fail_state(g_Error) does not allow for the plugin to function. It disables it as it has failed to connect to the database. Your server won't crash, but plugin won't work either.
DjSoftero is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode