SA-MP Forums Archive
Comaparing a String with a 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: Comaparing a String with a Variable (/showthread.php?tid=64087)



Comaparing a String with a Variable - ICECOLDKILLAK8 - 01.02.2009

Is there anyway to compare a String with a Variable?



Re: Comaparing a String with a Variable - Ghett0 - 01.02.2009

Quote:
Originally Posted by JeNkStAX
Is there anyway to compare a String with a Variable?
Returns 0 if the var and the string are the same.
pawn Код:
StrFloatCmp(str:String, Float:Float, Chars) // Float is the float to compare, chars is the number of characters to compare
{
    new StrFloat[10];
    format(StrFloat, sizeof(StrFloat), "%f", Float);
    if (strcmp(StrFloat, String, true, Chars) == 0) return 0;
    return 1;
}

StrIntCmp(str:String, int:Integer, Chars) // Float is the float to compare, chars is the number of characters to compare
{
    new StrInt[10];
    format(StrInt, sizeof(StrInt), "%i", Integer);
    if (strcmp(StrInt, String, true, Chars) == 0) return 0;
    return 1;
}



Re: Comaparing a String with a Variable - ICECOLDKILLAK8 - 01.02.2009

I want to comapre this and your method would not work for hat i need it for, heres a lil snippet of my code
Код:
format(timedate, sizeof(timedate), "%d%d%d%d%d", svrsec, svrmin, svrhr, svrday, svrmonth);
if(AccountInfo[playerid][Jail] >= timedate)



Re: Comaparing a String with a Variable - Donny_k - 02.02.2009

Format both into strings and compare them.


Re: Comaparing a String with a Variable - Ghett0 - 02.02.2009

Quote:
Originally Posted by Donny
Format both into strings and compare them.
That's exactly what mine does.


Re: Comaparing a String with a Variable - yom - 02.02.2009

strval

but you don't think enough of what you try to do here:

pawn Код:
format(timedate, sizeof(timedate), "%d%d%d%d%d", svrsec, svrmin, svrhr, svrday, svrmonth);
and why to do so complicated lol


Re: Comaparing a String with a Variable - ICECOLDKILLAK8 - 02.02.2009

Im doin a jail system where people can do time while they are offline and i wanna get time and date all in to one number


Re: Comaparing a String with a Variable - yom - 02.02.2009

Then just use gettime() lol..


Re: Comaparing a String with a Variable - ICECOLDKILLAK8 - 02.02.2009

i am lol
Код:
gettime(svrhr,svrmin,svrsec);
getdate(svryear,svrmonth,svrday);
format(timedate, sizeof(timedate), "%d%d%d%d%d", svrsec, svrmin, svrhr, svrday, svrmonth);
and thanks btw, using strval worked


Re: Comaparing a String with a Variable - yom - 02.02.2009

Use:

gettime();