split a variables or separate variable - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: split a variables or separate variable (
/showthread.php?tid=206930)
split a variables or separate variable -
Fab10 - 04.01.2011
I have a Variable-where inside there is a date. How do I separate the variable day, month and year?
Thanks, sorry for the shitty English, I'm Italian ..
Es:
I have
new str[24];
str = 2011-01-04;
do you want separate 2011, 01, 04 do you set in other varables??
new year, mont, day;
year = 2011 ecc....
Re: split a variables or separate variable -
GaGlets(R) - 04.01.2011
pawn Код:
strmid(str,"2011-01-04",0,12,13);
then use sscanf from ******
pawn Код:
sscanf(str, "p<->iii", year, month, day);
//or
sscanf("2011 01 04", "iii", year month, day); // etc
Re: split a variables or separate variable -
Fab10 - 04.01.2011
Код:
if(PlayerInfo[playerid][pPremium] == 1)
{
new Year, Month, Day, day, month, year;
//sscanf(PlayerInfo[playerid][pScadenza], "iii", year month, day);
strmid(PlayerInfo[playerid][pScadenza],PlayerInfo[playerid][pScadenza],year,month,day);
printf("%02d/%02d/%d", day, month, year);
getdate(Year, Month, Day);
if(Day < day && Month > month || Day > day && Month == month || Year > year)
{
PlayerInfo[playerid][pPremium] = 0;
SendClientMessage(playerid, COLOR_WHITE, "Il tuo abbonamento a premium user и scaduto.");
}
if(PlayerInfo[playerid][pPremium] == 1)
{
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Il tuo abbonamento a premium user scade il %02d/%02d/%d", day, month, year);
}
}
printf return 00/00/0
Re: split a variables or separate variable -
Fab10 - 04.01.2011
help me
Re: split a variables or separate variable -
Jefff - 04.01.2011
This PlayerInfo[playerid][pScadenza] = "2011-01-04" ?
Re: split a variables or separate variable -
Fab10 - 04.01.2011
yes do you separate??