doesn't change
#1

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
Reply
#2

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

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;

Reply
#4

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

Reply
#5

what is strcmp?

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

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;
}
Reply
#7

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.
Reply
#8

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

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;
}
?
Reply
#10

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.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)