SA-MP Forums Archive
Small question about a command - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Small question about a command (/showthread.php?tid=103013)



Small question about a command - dirkblok - 18.10.2009

Hello,

How can I make a command that only if you are named "dirkblok" you can do the command?

So the player needs to have the playername dirkblok to use the command...

thanks alot guys

Dirk


Re: Small question about a command - saiberfun - 18.10.2009

Quote:
Originally Posted by dirkblok
Hello,

How can I make a command that only if you are named "dirkblok" you can do the command?

So the player needs to have the playername dirkblok to use the command...

thanks alot guys

Dirk
how about reading the wiki? -_-

https://sampwiki.blast.hk/wiki/Using_strcmp%28%29
https://sampwiki.blast.hk/wiki/GetPlayerName
juz compare if it is "dirkblok"


Re: Small question about a command - dirkblok - 18.10.2009

Thanks but... Can you explain this for me?

So I need to create a GetPlayerName(playerid, name, sizeof(name));

and then :

if GetPlayerName(playerid, name,sizeof(name)) == dirkblok
{
// everything
}
else
{
SendClientMessage(playerid, COLOR, "you are not dirkblok");
}

am I right?

Thanks


Re: Small question about a command - Djiango - 18.10.2009

pawn Код:
new name[24];
GetPlayerName(playerid, name, sizeof(name));//Get the name here.
if(strcmp(name, "dirkblok", true) == 0)//Match name with dirkblok
{
  //do something
}
else
{
  SendClientMessage(playerid, COLOR, "You're not dirkblok!");
}



Re: Small question about a command - Tigerbeast11 - 18.10.2009

you can do:

Код:
if (GetPlayerName(playerid) == dirkblok)
{
 //You cmd
}
else
{
 SendClientMessage(playerid, 0xFFFF00FF,"You are not dirkblok!");
}
Should work, post here if any errors...


Re: Small question about a command - Correlli - 18.10.2009

No Tigerbeast11, you can't use GetPlayerName like that.
https://sampwiki.blast.hk/wiki/GetPlayerName


Re: Small question about a command - dirkblok - 18.10.2009

Thanks alot guys