mysql work contract check
#1

PHP код:
YCMD:clean(playeridparams[], help){
    print(
"works");
    
mysql_query("SELECT pName,WorkId, WorkContract FROM users WHERE WorkId > '-1'");
    
mysql_store_result();
    new 
vardas[MAX_PLAYER_NAME], darboiddarboKontraktasresultline[300];
    while(
mysql_fetch_row_format(resultline))
    {
        
sscanf(resultline,"p<|>s[24]ii",vardasdarboiddarboKontraktas);
        if(
gettime() > darboKontraktas){
            if(
GetPlayeridMid(vardas) != INVALID_PLAYER_ID) return 0
            
format(g_szBuffersizeof g_szBuffer"UPDATE `"MySQL_PLAYERS_TABLE"` SET `WorkId` = '-1', `WorkStatus` = '0', `WorkPoints` = '0', `WorkWarns` = '0', `WorkRank` = '0' WHERE pName = '%s'"vardas);
            
mysql_query(g_szBuffer);
            
frakcija[darboid][fSlotUsed] -= 1;
            
updateFractionLabel(darboid);
            
format(zinute128"{A17800}[ %s ]{785A00} darbuotojo {A17800}%s{785A00} darbo kontrakto laikas baigėsi, jis iљmestas."GetPlayerRadioJob(darboid), vardas);
            
SendMessageToFraction(darboidzinute);
            
printf("%s zaidejui kontraktas baigesi"vardas);
        }
    }
    
mysql_free_result();
    return 
1;

Hi guys, I created this code for me and he's kind a work's and kinda don't work. The problem is that in Database there is 2 players, but this code checks only 1 player. Bouth player WorkId == 7

On this part:
PHP код:
if(GetPlayeridMid(vardas) != INVALID_PLAYER_ID) return 0
If the player I check on database is online I dont wan't to effect him.

DEBUG:
PHP код:
[17:06:54CMySQLHandler::Query(SELECT pName,WorkIdWorkContract FROM users WHERE WorkId '-1') - Successfully executed.
[
17:06:54] >> mysql_store_resultConnection handle)
[
17:06:54CMySQLHandler::StoreResult() - Result was stored.
[
17:06:54] >> mysql_fetch_row_formatConnection handle)
[
17:06:54CMySQLHandler::FetchRow() - Return: Trevor_Phillipss|7|1437219760 
Reply
#2

Its because you're returning there, it returns from the entire function, ie ending it.

Would be better to change your if statement to
PHP код:
If(GetPlayeridMid(vardas) == INVALID_PLAYER_ID){
//rest of code here

Reply
#3

Or use
pawn Код:
continue;
instead of return
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)