How do I check if a string Equals a certain word?
#1

pawn Код:
COMMAND:gender(playerid,params[])
{
    SetPVarString(playerid,"Gender",params);
    new strz[38];
    format(strz,sizeof(strz), "Your gender is now set to: %s.",params);
    SendClientMessage(playerid, blue, strz);
    return 1;
}
I want to check if 'params' doesn't equal Male or Female (and if possible ignoring the case, so fEmAle still equals Female).
and if it doesn't then stops the command and sends a Invalid gender message.
Well heres how I would do it in java..
Код:
if(!params.equalsIgnoreCase("male") || params.equalsIgnoreCase("Female"))
But I have no idea how pawn strings work, I just learned about the lengths being how many characters are in it +1 for the null character ending the string...

Thanks for reading.


Bonus question :
Is 12 characters long enough for an Accent?
And should it be >= 14 because of the null characters on strings?
Код:
COMMAND:accent(playerid,params[])
{
    if(strlen(params) >= 13)
    {
        SendClientMessage(playerid, blue, "[LENGTH ERROR] Accent cannot be over 12 characters long.");
        return 1;
    }
	SetPVarString(playerid,"Accent",params);
	new strz[44];
	format(strz,sizeof(strz), "Your accent is now set to: %s.",params);
	SendClientMessage(playerid, blue, strz);
	return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)