Problem with this code
#1

Код:
public OnPlayerRequestSpawn(playerid)
{
new PlayerName[24];
if(GetPlayerSkin(playerid) == 100)
 {
    if(strcmp(PlayerName,"radek",true))
    {
        SendClientMessage(playerid,0x33AA33AA, "-Ident-Hey ;)");
        return 1;
    }
    else
    {
        SendClientMessage(playerid,0x33AA33AA, "-Ident-You can't choose this class.");
        return 0;
    }
}
return 1;
}
How i can make it to work, if i choose this skin, as "radek" it keep saying i cant choose it, and if i go in server with name "tttt" same thing happend, its unselectable by everyone. Can some show me correct code?
Reply
#2

Learn the proper strcmp usage.
https://sampwiki.blast.hk/wiki/Strcmp
Reply
#3

You need use GetPlayerName

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
new PlayerName[24];
GetPlayerName(playerid, PlayerName, 24);
if(GetPlayerSkin(playerid) == 100)
 {
    if(strcmp(PlayerName,"radek",true) == 0)
    {
        SendClientMessage(playerid,0x33AA33AA, "-Ident-Hey ;)");
        return 1;
    }
    else
    {
        SendClientMessage(playerid,0x33AA33AA, "-Ident-You can't choose this class.");
        return 0;
    }
}
Reply
#4

Quote:
Originally Posted by Josma_cmd
Посмотреть сообщение
You need use GetPlayerName

...
}[/pawn]
You are still missing the string to compare - the getplayername should be there.
Reply
#5

He's comparing the string stored in the variable playername with what's between the quotes.
He does not need another string.
See the strcmp.
Reply
#6

Код:
public OnPlayerRequestSpawn(playerid)
{
new PlayerName[24];
GetPlayerName(playerid, PlayerName, 24);
if(GetPlayerSkin(playerid) == 100)
{
if(strcmp(PlayerName,"radek",true) == 0)
{
SendClientMessage(playerid,0x33AA33AA, "-Ident-Hey ;)");
return 1;
}
else
{
SendClientMessage(playerid,0x33AA33AA, "-Ident-You can't choose this class.");
return 0;
}
}
return 1;
}
I think this is the code.
Solved maybe.
Reply
#7

Quote:
Originally Posted by RadekB0Y
Посмотреть сообщение
Код:
public OnPlayerRequestSpawn(playerid)
{
new PlayerName[24];
GetPlayerName(playerid, PlayerName, 24);
if(GetPlayerSkin(playerid) == 100)
{
if(strcmp(PlayerName,"radek",true) == 0)
{
SendClientMessage(playerid,0x33AA33AA, "-Ident-Hey ;)");
return 1;
}
else
{
SendClientMessage(playerid,0x33AA33AA, "-Ident-You can't choose this class.");
return 0;
}
}
return 1;
}
I think this is the code.
Solved maybe.
Yes, this one should work. Try it out.
Reply
#8

Ye its working, can i ask for one last thing if i wanna reserve the skin for more people than 1. how i can do it?
Reply
#9

Here's an example of doing it:
pawn Код:
if(strcmp(PlayerName,"radek",true) || strcmp(PlayerName,"OtherNames",true) == 0)
Reply
#10

it doesnt work, it make skin clearly selectable by everyone. Are you sure this code works?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)