mysql work contract check - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: mysql work contract check (
/showthread.php?tid=582238)
mysql work contract check -
bogushas - 19.07.2015
PHP код:
YCMD:clean(playerid, params[], help){
print("works");
mysql_query("SELECT pName,WorkId, WorkContract FROM users WHERE WorkId > '-1'");
mysql_store_result();
new vardas[MAX_PLAYER_NAME], darboid, darboKontraktas, resultline[300];
while(mysql_fetch_row_format(resultline))
{
sscanf(resultline,"p<|>s[24]ii",vardas, darboid, darboKontraktas);
if(gettime() > darboKontraktas){
if(GetPlayeridMid(vardas) != INVALID_PLAYER_ID) return 0;
format(g_szBuffer, sizeof 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(zinute, 128, "{A17800}[ %s ]{785A00} darbuotojo {A17800}%s{785A00} darbo kontrakto laikas baigėsi, jis iљmestas.", GetPlayerRadioJob(darboid), vardas);
SendMessageToFraction(darboid, zinute);
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:54] CMySQLHandler::Query(SELECT pName,WorkId, WorkContract FROM users WHERE WorkId > '-1') - Successfully executed.
[17:06:54] >> mysql_store_result( Connection handle: 1 )
[17:06:54] CMySQLHandler::StoreResult() - Result was stored.
[17:06:54] >> mysql_fetch_row_format( Connection handle: 1 )
[17:06:54] CMySQLHandler::FetchRow() - Return: Trevor_Phillipss|7|1437219760
Re: mysql work contract check -
!damo!spiderman - 19.07.2015
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
}
Re: mysql work contract check -
Misiur - 19.07.2015
Or use
instead of return