Problem after mysql_fetch_row_format
#1

FIXED THANKS
Reply
#2

For starters it should be

pawn Код:
SecondsToDHMS (dbt - times, days, hours, mins, sec);
but it probably won't return a exact integer value such as 3 days. It is going to return a float.

You should just do the following:
pawn Код:
new time = floatround((dbt - times) / 86400), floatround_ceil);
Reply
#3

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
For starters it should be

pawn Код:
SecondsToDHMS (dbt - times, days, hours, mins, sec);
but it probably won't return a exact integer value such as 3 days. It is going to return a float.

You should just do the following:
pawn Код:
new time = floatround((dbt - times) / 86400), floatround_ceil);
pawn Код:
SecondsToDHMS (dbt - times, days, hours, mins, sec);
You are right about it , but i also try that ,but the problem its still say this time its show -value(-15705)


pawn Код:
new time = floatround((dbt - times) / 86400), floatround_ceil);
Same result as above -15705.

Im starting to thing there is a bug/problem after mysql_fetch_row_format becose i've predefine value (at PlayerInfo[playerid][pUtime]) and when i convert it after while loop its show correct days so i doubt the problem its somewere else , but thanks for ideas i appreciate it
Reply
#4

Still havent way to fix it . Thanks
Reply
#5

New day and still wont work normal
Reply
#6

I appreciate you PMing me, here are a few suggestions:
1. Do not use the loop. You explicitly are dealing with one ROW of data only, so the looping is not necessary. Additionally you could (perhaps should, depending on your system design) add a LIMIT 1 clause to the query.
2. Select only the necessary fields - SELECT field1,field2,field3,... FROM table (in your case, SELECT unban_time,reason FROM bans WHERE ...)
(3. Use better means of parsing. Your current method is slow and most likely working, but maybe not.)

Also jesus christ I've never seen a function such as SecondsToDHMS. It keeps on carrying the initial calculation on to the others - I don't think that's very good given the fact that PAWN is slow on calculations in the first place.
Reply
#7

Its still the same problem , even i try wich [HiC]TheKiller convertion
pawn Код:
new time = floatround((dbt - times) / 86400), floatround_ceil);
Reply
#8

Why are you making it yourself so hard, if SQL includes all functions that you need,
I show you how I make temporary bans,
First you create a column in your ban table with is type; timestamp
Then you insert a ban like:

Код:
 INSERT INTO `bans`(`username`, `start_date`, `expire_date`) VALUES ('%s', NOW(), NOW()+INTERVAL 10 DAY)
Now you banned this person for 3 days.

Then when the players connect and you check if he is banned, and when it expires you simply use thigs:

Код:
SELECT *,UNIX_TIMESTAMP(expire_date) AS timestamp FROM `bans` WHERE `username` = '%s' AND `IP` = '%s' AND `banned` = 1
Then you put this timestamp in a variable (int)
Then you use
pawn Код:
new timestamp;
// put your 'timestamp' from the sql results inside the timestamp variable.
if(timestamp < gettime())
{
// the player should get unbanned because it's expired
}
else
{
// players should get kicked because he is still banned.
}
Reply
#9

https://sampforum.blast.hk/showthread.php?tid=394765

Take a look.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)