SA-MP Forums Archive
doesn't change - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: doesn't change (/showthread.php?tid=526340)



doesn't change - saffierr - 16.07.2014

Since you guys, helped me thanks, Now I know how to work CORRECTLY with sscanf and the data's. thanks for that.

The following CMD is this /setcolor, so that the admin can change any player his color. I know that I miss something in my cmd, but I don't know what I miss.

This works: when I type /setcolor
it says USAGE: /setcolor [playerid] [color]

but when I do /setcolor 0 blue, my color appears to black, I can't change the colors? why?
everything works except the color changes


Re: doesn't change - Clad - 16.07.2014

Can you show us the Command atleast ? We're not magicians.


Re: doesn't change - saffierr - 16.07.2014

PHP код:
CMD:setcolor(playeridparams[])
{
    new 
idcolor;
    if (
sscanf(params"ud"idcolor)) return SendClientMessage(playeridCOLOR_WARN"USAGE: /setcolor [player id] [color]");
        
    if (!
IsPlayerAdmin(playerid)) return  SendClientMessage(playerid, -1"SERVER: Unknown command.");
    else if (
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_WARN"Requested player was not found!");
    else if (
IsPlayerAdmin(playerid))
    
SetPlayerColor(idcolor);
        
    
SendClientMessage(playeridCOLOR_WARN"You succesfully changed the player's color.");
        
    return 
1;




Re: doesn't change - R0 - 16.07.2014

What a big mistake you have done,First of all you have to define blue ,so it will set the color to blue -_-,i will make an example for you and make the others like the example i have made:
PHP код:
CMD:setcolor(playeridparams[]) 

    new 
idcolor
    if (
sscanf(params"ud"idcolor)) return SendClientMessage(playeridCOLOR_WARN"USAGE: /setcolor [player id] [color]"); 
         
    if (!
IsPlayerAdmin(playerid)) return  SendClientMessage(playerid, -1"SERVER: Unknown command."); 
    else if (
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_WARN"Requested player was not found!"); 
    if(
strcmp(color"blue"true) == 0)
    {
         
SetPlayerColor(id0x007BD0FF); 
         
SendClientMessage(playeridCOLOR_WARN"You succesfully changed the player's color."); 
    }
    return 
1




Re: doesn't change - saffierr - 16.07.2014

what is strcmp?

if(strcmp(color, "blue", true) == 0)
gives me errors on other cmds...


Re: doesn't change - Clad - 17.07.2014

pawn Код:
CMD:setcolor(playerid, params[])
{
new id, color;

    if (sscanf(params, "ud", id, color)) return SendClientMessage(playerid, COLOR_WARN, "USAGE: /setcolor [player id] [color]");  
if (!IsPlayerAdmin(playerid)) return  SendClientMessage(playerid, -1, "SERVER: Unknown command.");

    else if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WARN, "Requested player was not found!");  
if(strcmp(color, "blue", true) == 0)
    {
         SetPlayerColor(id, 0x007BD0FF);
         SendClientMessage(playerid, COLOR_WARN, "You succesfully changed the player's color.");
    }
    return 1;
}



Re: doesn't change - Jack_Leslie - 17.07.2014

Quote:
Originally Posted by saffierr
Посмотреть сообщение
what is strcmp?

if(strcmp(color, "blue", true) == 0)
gives me errors on other cmds...
strcmp is string compare.
it compares the first instance with the second instance, in this case the first instance is "color", which is what you input. it compares it with the second instance, in this case "blue". true means "not case-sensitive", but if you were to change true to false, it would be case sensitive. so if true was false, "blue" and "Blue" would be different. how ever in this case it's true, so "blue" and "Blue" are the same.


Re: doesn't change - saffierr - 17.07.2014

Good explanation, thanks.However I still want this fixed, my color doesn't change.


Re: doesn't change - Jack_Leslie - 17.07.2014

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Good explanation, thanks.However I still want this fixed, my color doesn't change.
Quote:
Originally Posted by Clad
pawn Код:
CMD:setcolor(playerid, params[])
{
new id, color;

    if (sscanf(params, "ud", id, color)) return SendClientMessage(playerid, COLOR_WARN, "USAGE: /setcolor [player id] [color]");  
if (!IsPlayerAdmin(playerid)) return  SendClientMessage(playerid, -1, "SERVER: Unknown command.");

    else if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WARN, "Requested player was not found!");  
if(strcmp(color, "blue", true) == 0)
    {
         SetPlayerColor(id, 0x007BD0FF);
         SendClientMessage(playerid, COLOR_WARN, "You succesfully changed the player's color.");
    }
    return 1;
}
?


Re: doesn't change - saffierr - 17.07.2014

It has 1 error,
Quote:

if(strcmp(color, "lightblue", true) == 0)

Quote:

C:\Users\selma\Desktop\Samp\gamemodes\Lerenscripte n.pwn(553) : warning 217: loose indentation
C:\Users\selma\Desktop\Samp\gamemodes\Lerenscripte n.pwn(557) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.