pTempVIP length left - 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: pTempVIP length left (
/showthread.php?tid=300785)
pTempVIP length left -
Roberto Saviano - 01.12.2011
Hello, i am currently trying to get the /stats command to show how many days, hours, minutes and seconds you got left of your membership, please be aware of that when you input pTempVIP = 3600 it is seconds.
This is how it looks alike, however it returns the seconds you got straight away to the ''days'' instead of the days, and doesnt ends up with anything into the remaining spots at all.
Код:
format(coordsstring, sizeof(coordsstring), "VIP time left: %d days %d hours %d minutes %d seconds.", ((PlayerInfo[targetid][pTempVIP]/3600)/24,PlayerInfo[targetid][pTempVIP]/60,PlayerInfo[targetid][pTempVIP]/3600,PlayerInfo[targetid][pTempVIP]));
SendClientMessage(playerid, COLOR_GRAD1, coordsstring);
Re: pTempVIP length left -
Roberto Saviano - 02.12.2011
Anyone ?
Re: pTempVIP length left -
AndreT - 02.12.2011
I'm having doubts about the method you showed above. Instead I would do something like:
I quickly came up with this method:
pawn Код:
new days, hours, minutes, seconds = PlayerInfo[targetid][pTempVIP];
days = seconds / 86400;
seconds -= days * 86400;
hours = seconds / 3600;
seconds -= hours * 3600;
minutes = seconds / 60;
seconds -= minutes * 60;
format(coordsstring, sizeof(coordsstring), "VIP time left: %d days %d hours %d minutes %d seconds.", days, hours, minutes, seconds);
SendClientMessage(playerid, COLOR_GRAD1, coordsstring);
I doubt this is the best way to do it. So if anyone with more experience or with better code sees this, I'd love your input!
Re: pTempVIP length left -
Roberto Saviano - 02.12.2011
Thanks, i will try this out once i get home and see what happends
Edit: It works perfectly, thank you very much