string
#1

how can i disassemble a value? i mean... i have this:
new num;
how can i check if the first char is something?
Reply
#2

pawn Код:
if(num[0] != 0)
Also, take a look at my tutorial https://sampforum.blast.hk/showthread.php?tid=284112
Reply
#3

but my num is without cells...
Reply
#4

Quote:
Originally Posted by omer5198
Посмотреть сообщение
but my num is without cells...
Strings are multi-celled rather then single celled. You cannot have a string without multiple cells, each character has a cell, read the tutorial. If you have a number and you want to find the first number. Convert it like this

pawn Код:
new num = 954398085904, string[25];
format(string, 25, "%d", num);
printf("%c", string[0]):
That will print 9.
Reply
#5

lol you came to ask here?
hint: you don't need to convert the value to string. you can check the digits of a number by using division and remainder.
Reply
#6

ok... DeadlyBoy... i just wanted to see why Ron's Answer was wrong...
Reply
#7

because when using char value as integer it returns the Unicode value.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)