Jump to content

IsNumeric


AvestX

Recommended Posts

Dobrý den ..

Dávám další TuT .. tato funkce není má ! vytvořil jí DracoBlue, ale vím jak jí použít(vat) tak dávám TuT ..


Definace funkce:

stock IsNumeric(const string[])
{
new length=strlen(string);
if (length==0) return false;
for (new i = 0; i < length; i++)
{
	if ((string[i] > '9' || string[i] < '0' && string[i]!='-' && string[i]!='+')|| (string[i]=='-' && i!=0)|| (string[i]=='+' && i!=0)) return false;
}
if (length==1 && (string[0]=='-' || string[0]=='+')) return false;
return true;
}


použití:

DCMD asi máte nadefinované tak vytvořte příkaz a třeba takto:

dcmd_money(playerid, params[])
{
new castka = strval(params);
if(!IsNumeric(params)) return SendClientMessage(playerid, 0xFFFFFFFF, "Zadej /money [Castka] !"); // Pokud nezadá číslo
GivePlayerMoney(playerid, castka);

return 1;
}

nebo když chcete aby nešlo číslo

if(IsNumberic(params)) return SendClientMessage(playerid, 0xFFFFFFFF, "Nesmíš zadat čáslo !");

Link to comment
Share on other sites

Ach náš marw :d

tak si to dej

 

stock IsNumeric(const string[]){new length=strlen(string);if (length==0) return false;for (new i = 0; i < length; i++){if ((string > '9' || string < '0' && string!='-' && string!='+')|| (string=='-' && i!=0)|| (string=='+' && i!=0)) return false;}if (length==1 && (string[0]=='-' || string[0]=='+')) return false;return true;}

 

Link to comment
Share on other sites

j je to dobra funkce chvili sem ji pouzival

fuguje jednoduse vlastne porovnava vsecky znaky v retezci a povolene sou 0 1 2 3 4 5 6 7 8 9 - + kdyz tam je jiny znak tak to odesle false jako ze to neni ciselne a kdyz tam sou tyto znaky tak true

Link to comment
Share on other sites

Přesně atomasi ...

Hodí se to třeba když chceš aby sem něco poslal nejákýmu ID a zadá třeba

/kill [iD]

a místo id dá

/kill _aVeStX_

a

if(!IsNumberic(params)) return SCM(i, color, "Musis zadat ID !");

a podobne ptakoviny :d

Link to comment
Share on other sites

Ach náš marw :d

tak si to dej

 

stock IsNumeric(const string[]){new length=strlen(string);if (length==0) return false;for (new i = 0; i < length; i++){if ((string > '9' || string < '0' && string!='-' && string!='+')|| (string=='-' && i!=0)|| (string=='+' && i!=0)) return false;}if (length==1 && (string[0]=='-' || string[0]=='+')) return false;return true;}

 

Pořád moc dlouhé xD

hele....

IsNumeric(string[]) { for (new i = 0, j = strlen(string); i < j; i++) if (string[i] > '9' || string[i] < '0') return 0; return 1; }

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...