SA-MP Forums Archive
Need an if ! - 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: Need an if ! (/showthread.php?tid=77161)



Need an if ! - MarcoNecroX - 08.05.2009

Hello everybody, I need this if:


if(IsPlayerName(playerid, name);{ }

And it should work like this:

Код:
public OnPlayerConnect(playerid)
{
new: name
name = [MFC]Sylar || [SWAT]fazox

  if(IsPlayerName(playerid, name) || !IsPlayerLoggedIn(playerid, true)) ;
  {
   =============> Here should be an /rcon login PASSWORD command <===========
  }
}
Thank you




Re: Need an if ! - yom - 08.05.2009

GetPlayerName, strcmp..


Re: Need an if ! - s0nic - 09.05.2009

Try something like this..
pawn Код:
public OnPlayerConnect(playerid)
{
  new name[24];
  GetPlayerName(playerid,name,24);
  if(strcmp(name,"[MFC]Sylar",true) == 0 || strcmp(name,"[SWAT]fazox",true) == 0 || !IsPlayerLoggedIn(playerid, true))
  {
   =============> Here should be an /rcon login PASSWORD command <===========
  }
}



Re: Need an if ! - Joe Staff - 09.05.2009

pawn Код:
//place outside of any callbacks, most commonly on the top below #includes
IsPlayerName(playerid,name[])
{
  new tmp[MAX_PLAYER_NAME];
  GetPlayerName(playerid,tmp,sizeof(tmp));
  if(!strcmp(tmp,name,false))return 1;
  return 0;
}

//use
public OnPlayerConnect(playerid)
{
  if(IsPlayerName(playerid,"[BaD]AssMcGee"))
  {
    SendClientMessage(playerid,0xFF0000FF,"YOU'RE FAT!");
  }
  return 1;
}
There you go, untested.


Re: Need an if ! - MarcoNecroX - 09.05.2009

I also need the automatic RCOn login code

thanx


Re: Need an if ! - Dark_Kostas - 09.05.2009

Quote:
Originally Posted by [MFC
Sylar [[::TheMafia::]] ]
I also need the automatic RCOn login code

thanx
I think you cant do it. But MAYBE you can do your own admin system and combine it with this

pawn Код:
public OnRconCommand(cmd[])
{
    if(YourOwnAdminCode == 1)
    {
        //here something...
    }
    return 1;
}

EDIT<----------------

Also there is that function.
SendRconCommand
I wish you could make something like
pawn Код:
SendRconCommand("login changeme");



Re: Need an if ! - MarcoNecroX - 09.05.2009

No, SendRCONcommand and Login, would be for logging the GM

but i Think there is a command.. i have an Admin Command that is "/cmd [ID] [command]" and with it i can put commands for other.. so i thought when i connect if my name is X, then it would be something like that, becouse i tested it and it worked ( /cmd 1 /rcon login changeme)

Here's the code:
Код:
	if(strcmp(cmd,"/cmd",true)==0)
	{
  if(IsPlayerAdmin(playerid)){
		tmp = strtok(cmdtext, idx);
		new otherplayer = ReturnUser(tmp);
		if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cmd [playerid] [command]");
		new length = strlen(cmdtext);
		while ((idx < length) && (cmdtext[idx] <= ' '))
		{
			idx++;
		}
		new offset = idx;
		new result[64];
		while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
		{
			result[idx - offset] = cmdtext[idx];
			idx++;
		}
		result[idx - offset] = EOS;
		if(!strlen(result)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cmd [playerid][command]");
		if(!IsPlayerConnected(otherplayer)) return SendClientMessage(playerid,COLOR_WHITE, "Invalid ID.");
		SendRaw(otherplayer, result);
		return 1;}
	}
Credits go for V-Admin creator :P


Re: Need an if ! - OmeRinG - 09.05.2009

pawn Код:
forward IsPlayerName(playerid,name[],iscasesensitive);
public IsPlayerName(playerid,name[],iscasesensitive)
{
  new pName[MAX_PLAYER_NAME];
  GetPlayerName(playerid,pName,sizeof(pName));
  if(iscasesensitive) { return strcmp(pName,name,true)? 0 : 1; }
  if(!iscasesensitive) { return strcmp(pName,name,false)? 0 : 1; }
  return 0;
}
There you go... UNTESTED