string &? switch
#1

Hey i`m a bit confused now.

How can i switch string / use switch checking the string

pawn Code:
new name[15];
        if(sscanf(params, "s[15]", name))
        {
            return 1;
        }
        format(name, 15,"%s",name);
        switch(name)
        {
            case 'sell':
            {
                    .......................
This is giving errors for me.

Do i need to use strcmp or smth like that?
Reply
#2

You cannot switch on a string in pawn, switch may only be used with integers. Also you don't need that format, sscanf formats name automatically. You will need to use strcmp and if/else if.
Reply
#3

You could do something like this: http://forum.sa-mp.com/showthread.ph...ighlight=yhash.

Other than that you have to use strcmp to compare to strings together.
Reply
#4

*DELETED*
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)