simple convert
#1

i have no idea what to convert this part to not sure if i need to or what but anyways can you guys tell me.

Код:
COMMAND:ooc(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 1)
 	{
		if(sscanf(params,"s[128]", string))
     	{
      		SendClientMessage(playerid, COLOR_WHITE2, "Function: {FFFFFF}/ooc off/on ");
        	return 1;
       	}
        if(strcmp(tmp,"off",true) == 0) // this part
        {
        	ooc = 0;
         	SendClientMessageToAll(COLOR_RED,"[OOC]: Disabled");
          	PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
           	return 1;
	    }
     	else if(strcmp(tmp,"on",true) == 0) // this part
      	{
       		ooc = 1;
         	SendClientMessageToAll(COLOR_PINKY,"[OOC]: Enabled");
          	PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
           	return 1;
		}
	}
	else
	{
 		SendClientMessage(playerid,COLOR_WHITE2,"Your are not a high enough rank");
	}
	return 1;
}
Reply
#2

Quote:
Originally Posted by Yves
Посмотреть сообщение
i have no idea what to convert this part to not sure if i need to or what but anyways can you guys tell me.

Код:
COMMAND:ooc(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 1)
 	{
		if(sscanf(params,"s[128]", string))
     	{
      		SendClientMessage(playerid, COLOR_WHITE2, "Function: {FFFFFF}/ooc off/on ");
        	return 1;
       	}
        if(strcmp(tmp,"off",true) == 0) // this part
        {
        	ooc = 0;
         	SendClientMessageToAll(COLOR_RED,"[OOC]: Disabled");
          	PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
           	return 1;
	    }
     	else if(strcmp(tmp,"on",true) == 0) // this part
      	{
       		ooc = 1;
         	SendClientMessageToAll(COLOR_PINKY,"[OOC]: Enabled");
          	PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
           	return 1;
		}
	}
	else
	{
 		SendClientMessage(playerid,COLOR_WHITE2,"Your are not a high enough rank");
	}
	return 1;
}
What do you want to convert it to?
Reply
#3

never mind.
Reply
#4

You don't need sscanf for just 1 string, you could simply use isnull to check if the params if is null or it isn't null, then you could use the params[] to do everything, like on this code below.

pawn Код:
#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif

CMD:ooc(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] < 0)
            return SendClientMessage(playerid,COLOR_WHITE2,"Your are not a high enough rank");

    if( isnull( params ) )
            return SendClientMessage(playerid, COLOR_WHITE2, "Function: {FFFFFF}/ooc off/on ");

    if(strcmp(params,"off"))
    {
        ooc = 0;
        SendClientMessageToAll(COLOR_RED,"[OOC]: Disabled");
        PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
    }
    else if(strcmp(params, "on"))
    {
        ooc = 1;
        SendClientMessageToAll(COLOR_PINKY,"[OOC]: Enabled");
        PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
    }
    return 1;
}
Reply
#5

Код:
COMMAND:ooc(playerid, params[])
{
	if (PlayerInfo[playerid][pAdmin] >= 1)
 	{
        if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE2, "Function: {FFFFFF}/ooc off/on ");
        if(strcmp(params,"off",true) == 0) // this part
        {
        	ooc = 0;
         	SendClientMessageToAll(COLOR_RED,"[OOC]: Disabled");
          	PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
           	return 1;
	    }
     	else if(strcmp(params,"on",true) == 0) // this part
      	{
       		ooc = 1;
         	SendClientMessageToAll(COLOR_PINKY,"[OOC]: Enabled");
          	PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
           	return 1;
		}
           }
	}
	else
	{
 		SendClientMessage(playerid,COLOR_WHITE2,"Your are not a high enough rank");
	}
	return 1;
}
Just fix the loose indeniation.
Reply
#6

Quote:
Originally Posted by Patrick_
Посмотреть сообщение
You don't need sscanf for just 1 string, you could simply use isnull to check if the params if is null or it has some string on it, then you could use the params[] to do everything, like on this code below.

pawn Код:
#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif

CMD:ooc(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] < 0)
            return SendClientMessage(playerid,COLOR_WHITE2,"Your are not a high enough rank");

    if( isnull( params ) )
            return SendClientMessage(playerid, COLOR_WHITE2, "Function: {FFFFFF}/ooc off/on ");

    if(strcmp(params,"off"))
    {
        ooc = 0;
        SendClientMessageToAll(COLOR_RED,"[OOC]: Disabled");
        PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
    }
    else if(strcmp(params, "on"))
    {
        ooc = 1;
        SendClientMessageToAll(COLOR_PINKY,"[OOC]: Enabled");
        PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
    }
    return 1;
}
yeah my mistake thanks for that

but what about this part
if(strcmp(params,"off"))
and
else if(strcmp(params, "on"))
Reply
#7

-- deleted --
Reply
#8

If you don't want to use strcmp you can use y_stringhash by ******, the code is shown below, its easier than strcmp if you're a beginner, its faster by milliseconds because it doesn't use else if statement.

pawn Код:
CMD:ooc(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] < 0)
            return SendClientMessage(playerid,COLOR_WHITE2,"Your are not a high enough rank");

    if( isnull( params ) )
            return SendClientMessage(playerid, COLOR_WHITE2, "Function: {FFFFFF}/ooc off/on ");
       
    switch (YHash(params))
    {
        case _H<off>:
        {
            ooc = 0;
            SendClientMessageToAll(COLOR_RED,"[OOC]: Disabled");
            PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
        }
        case _H<on>:
        {
            ooc = 1;
            SendClientMessageToAll(COLOR_PINKY,"[OOC]: Enabled");
            PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
        }
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by Patrick_
Посмотреть сообщение
If you don't want to use strcmp you can use y_stringhash by ******, the code is improvement below, its easier than strcmp if you're a beginner, its faster by milliseconds because it doesn't use else if statement.

pawn Код:
CMD:ooc(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] < 0)
            return SendClientMessage(playerid,COLOR_WHITE2,"Your are not a high enough rank");

    if( isnull( params ) )
            return SendClientMessage(playerid, COLOR_WHITE2, "Function: {FFFFFF}/ooc off/on ");
       
    switch (YHash(params))
    {
        case _H<off>:
        {
            ooc = 0;
            SendClientMessageToAll(COLOR_RED,"[OOC]: Disabled");
            PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
        }
        case _H<on>:
        {
            ooc = 1;
            SendClientMessageToAll(COLOR_PINKY,"[OOC]: Enabled");
            PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
        }
    }
    return 1;
}
nice one thanks man i just didn't no what to convert it to
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)