Comaparing a String with a Variable
#1

Is there anyway to compare a String with a Variable?
Reply
#2

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;
}
Reply
#3

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)
Reply
#4

Format both into strings and compare them.
Reply
#5

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

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
Reply
#7

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
Reply
#8

Then just use gettime() lol..
Reply
#9

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
Reply
#10

Use:

gettime();
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)