SA-MP Forums Archive
Problem with this code - 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: Problem with this code (/showthread.php?tid=290424)



Problem with this code - RadekB0Y - 15.10.2011

Код:
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?


Re: Problem with this code - [MWR]Blood - 15.10.2011

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


Re: Problem with this code - Josma_cmd - 15.10.2011

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



Re: Problem with this code - [MWR]Blood - 15.10.2011

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

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


Re: Problem with this code - Josma_cmd - 15.10.2011

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.


Re: Problem with this code - RadekB0Y - 15.10.2011

Код:
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.


Re: Problem with this code - [MWR]Blood - 15.10.2011

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.


Re: Problem with this code - RadekB0Y - 15.10.2011

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?


Re: Problem with this code - [MWR]Blood - 15.10.2011

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



Re: Problem with this code - RadekB0Y - 15.10.2011

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