SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 17/05/2018, 06:34 PM   #1
Xportaler
Big Clucker
 
Xportaler's Avatar
 
Join Date: Feb 2017
Posts: 118
Reputation: 4
Default MySQL Table changin

Hello Guts! I have 2 variables saved in Database(Table) one count Hours(Vhours = theammount of hours) and another one check if its 1 or 0(Active= 1/0). I want to check this table and if VHours is more than 20 then set it to 0 and if active = 0 set it to 1
But the problem is i dont want to check only for players who Connect to the server but for all Table! Someone help me with this
__________________

Xportaler is offline   Reply With Quote
Old 17/05/2018, 06:39 PM   #2
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 604
Reputation: 18
Default Re: MySQL Table changin

Please provide an example and more details, what do you mean with
Quote:
i dont want to check only for players who Connect to the server but for all Table!
__________________

forum.nc-rp.cf
JasonRiggs is offline   Reply With Quote
Old 17/05/2018, 06:44 PM   #3
Xportaler
Big Clucker
 
Xportaler's Avatar
 
Join Date: Feb 2017
Posts: 118
Reputation: 4
Default Re: MySQL Table changin

PHP Code:
`plr_veteranSET `Actve`=1 WHERE `VHOURS` > 20"); 
But i want to set this for all database if they are VHOURS > 20 Not just for players who connect to server. I want to do it to all Table plr_veteran
__________________

Xportaler is offline   Reply With Quote
Old 17/05/2018, 06:50 PM   #4
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 604
Reputation: 18
Default Re: MySQL Table changin

For example making it under OnGameModeInIt?
__________________

forum.nc-rp.cf
JasonRiggs is offline   Reply With Quote
Old 17/05/2018, 06:51 PM   #5
Kraeror
Huge Clucker
 
Kraeror's Avatar
 
Join Date: Mar 2017
Location: Bulgaria
Posts: 426
Reputation: 19
Default Re: MySQL Table changin

Quote:
Originally Posted by Xportaler View Post
PHP Code:
`plr_veteranSET `Actve`=1 WHERE `VHOURS` > 20"); 
But i want to set this for all database if they are VHOURS > 20 Not just for players who connect to server. I want to do it to all Table plr_veteran
Can you show me the full line?
Kraeror is offline   Reply With Quote
Old 17/05/2018, 06:53 PM   #6
Xportaler
Big Clucker
 
Xportaler's Avatar
 
Join Date: Feb 2017
Posts: 118
Reputation: 4
Default Re: MySQL Table changin

This is what im trying to create! This is what i want to do but i dont know how to do it through pawn to edit it also for players who are not online and set it to 1 or 0 even for players who dont connect to server
__________________

Xportaler is offline   Reply With Quote
Old 17/05/2018, 06:56 PM   #7
Kraeror
Huge Clucker
 
Kraeror's Avatar
 
Join Date: Mar 2017
Location: Bulgaria
Posts: 426
Reputation: 19
Default Re: MySQL Table changin

Quote:
Originally Posted by Xportaler View Post
This is what im trying to create! This is what i want to do but i dont know how to do it through pawn to edit it also for players who are not online and set it to 1 or 0 even for players who dont connect to server
I understood, but show me more code, because there isn't any problem in the code you gave!
Kraeror is offline   Reply With Quote
Old 17/05/2018, 07:13 PM   #8
Xportaler
Big Clucker
 
Xportaler's Avatar
 
Join Date: Feb 2017
Posts: 118
Reputation: 4
Default Re: MySQL Table changin

PHP Code:
forward Checkveteran(); 
public 
Checkveteran() 

    for(new 
i;i<MAX_PLAYERS;i++) 
    { 
        if(
IsPlayerConnected(i)) 
        { 
            
pGeneral[i][PLR_VETERAN] = 0
            
pGeneral[i][OLD_HOURS] = 0
        } 
         
    } 
    
mysql_query_nodata("UPDATE `plr_veteran` SET `RANK_STATUS`=0,`RANK_UPDATED`=1"); 
     
mysql_query_nodata("UPDATE `plr_veteran` SET `RANK_STATUS`=1,`RANK_UPDATED`=1 WHERE `OLD_HOURS` > 20"); 
      
mysql_query_nodata("UPDATE plr_veteran SET `OLD_HOURS` = 0"); 
    return 
1

But now it will go more complicated!
this is variables im using now
__________________

Xportaler is offline   Reply With Quote
Old 17/05/2018, 07:15 PM   #9
Kraeror
Huge Clucker
 
Kraeror's Avatar
 
Join Date: Mar 2017
Location: Bulgaria
Posts: 426
Reputation: 19
Default Re: MySQL Table changin

Try this:
PHP Code:
mysql_query_nodata("SELECT * FROM `plr_veteran` ORDER BY `ID` ASC"); //Change the `ID` to the name of the variable which you are using line order
mysql_query_nodata("UPDATE `plr_veteran` SET `Actve`= '1' WHERE `VHOURS` > '20'"); 
I'm not sure if it will work! (I'm still learning MySQL)
EDITED: Code was edited a little!
Kraeror is offline   Reply With Quote
Old 17/05/2018, 07:16 PM   #10
JasonRiggs
Gangsta
 
Join Date: Jul 2016
Location: My bedroom.
Posts: 604
Reputation: 18
Default Re: MySQL Table changin

Under
PHP Code:
public OnGameModeInIt 
add
PHP Code:
Checkveteran(); 
to run a check for all, But the
PHP Code:
        if(IsPlayerConnected(i)) 
Should be removed because it will make the check only for online players..

EDIT:But don't forget to add under the function you sent the line which you sent us to make the main thing that you want..
__________________

forum.nc-rp.cf
JasonRiggs is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
MYSQL table Puff Scripting Help 8 01/09/2017 05:59 PM
MySQL: Update all values in table from another table kurta999 Scripting Help 8 23/08/2012 08:55 PM
Cars changin collors cruising Help Archive 6 19/02/2010 05:41 PM
changin player spawn weapons My_Waffles_Bitch_L0L Help Archive 2 13/02/2009 03:58 PM


All times are GMT. The time now is 10:54 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.