Help please
#1

This is my requestspawn:

Код:
public OnPlayerRequestSpawn(playerid)
{
  new playername[MAX_PLAYER_NAME];
	if(gTeam[playerid]==Team_Cops) // POLICE
	{
	  if(strcmp(playername,"LVC_Chrham2",false)==0)
	  {
	    SendClientMessage(playerid,COLOR_BLUE,"Welcome to you, Police Officer! You are now on duty and you must do your best to protect Chrham's City!");
	    return 1;
	  }
	  else
	  {
	  	SendClientMessage(playerid,COLOR_BLUE,"Only cops who have applied at the forums can spawn.");
	  	SendClientMessage(playerid,COLOR_BLUE,"http://chrhamrpg.one-forum.net/businesses-f6/");
	  	return 0;
		}
	}
	if(gTeam[playerid]==Team_FBI) // FBI
	{
	  if(strcmp(playername,"LVC_Chrham2",false)==0)
	  {
	    SendClientMessage(playerid,COLOR_BLUE,"Welcome to you, FBI Officer! You are now on duty and you must do your best to protect Chrham's City!");
	    return 1;
	  }
	  else
	  {
	  	SendClientMessage(playerid,COLOR_BLUE,"Only FBI Officers who have applied at the forums can spawn.");
	  	SendClientMessage(playerid,COLOR_BLUE,"http://chrhamrpg.one-forum.net/businesses-f6/");
	  	return 0;
		}
	}
	if(gTeam[playerid]==Team_Army) // ARMY
	{
	  if(strcmp(playername,"LVC_Chrham2",false)==0)
	  {
	    SendClientMessage(playerid,COLOR_BLUE,"Welcome to you guy in the army! You must do your best to protect Chrham's City!");
	    return 1;
	  }
	  else
	  {
	  	SendClientMessage(playerid,COLOR_BLUE,"Only armys who have applied at the forums can spawn.");
	  	SendClientMessage(playerid,COLOR_BLUE,"http://chrhamrpg.one-forum.net/businesses-f6/");
	  	return 0;
		}
	} else {
	return 1;
	}
}
Its supposed to lock the skin for evryone but LVC_Chrham2, but it dont work. Can you helep me?
Reply
#2

if(strcmp(playername,"LVC_Chrham2",false)==1)
Reply
#3

Quote:
Originally Posted by Ben^
if(strcmp(playername,"LVC_Chrham2",false)==1)
dont work.
Reply
#4

Your Code is correct except one thing is missing (Ben^ : strcmp returns 0 if the strings match. He did it correctly .).

Now what you did wrong is the you forgot to use "GetPlayerName" function. You created a string were to store it but you forgot to actually use the function. A small correction and it should work:

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
  new playername[MAX_PLAYER_NAME];
  GetPlayerName(playerid, playername, sizeof(playername));
  if(gTeam[playerid]==Team_Cops) // POLICE
    {
      if(strcmp(playername,"LVC_Chrham2",false)==0)
      {
        SendClientMessage(playerid,COLOR_BLUE,"Welcome to you, Police Officer! You are now on duty and you must do your best to protect Chrham's City!");
        return 1;
      }
      else
      {
        SendClientMessage(playerid,COLOR_BLUE,"Only cops who have applied at the forums can spawn.");
        SendClientMessage(playerid,COLOR_BLUE,"[url]http://chrhamrpg.one-forum.net/businesses-f6/"[/url]);
        return 0;
        }
    }
  if(gTeam[playerid]==Team_FBI) // FBI
    {
      if(strcmp(playername,"LVC_Chrham2",false)==0)
      {
        SendClientMessage(playerid,COLOR_BLUE,"Welcome to you, FBI Officer! You are now on duty and you must do your best to protect Chrham's City!");
        return 1;
      }
      else
      {
        SendClientMessage(playerid,COLOR_BLUE,"Only FBI Officers who have applied at the forums can spawn.");
        SendClientMessage(playerid,COLOR_BLUE,"[url]http://chrhamrpg.one-forum.net/businesses-f6/"[/url]);
        return 0;
        }
    }
  if(gTeam[playerid]==Team_Army) // ARMY
    {
      if(strcmp(playername,"LVC_Chrham2",false)==0)
      {
        SendClientMessage(playerid,COLOR_BLUE,"Welcome to you guy in the army! You must do your best to protect Chrham's City!");
        return 1;
      }
      else
      {
        SendClientMessage(playerid,COLOR_BLUE,"Only armys who have applied at the forums can spawn.");
        SendClientMessage(playerid,COLOR_BLUE,"[url]http://chrhamrpg.one-forum.net/businesses-f6/"[/url]);
        return 0;
        }
    } else {
    return 1;
    }
}
Other Reference:
https://sampwiki.blast.hk/wiki/Strcmp - Definition of strcmp
https://sampwiki.blast.hk/wiki/GetPlayerName - Definition of GetPlayerName
Reply
#5

if(!strfind(playername,"LVC_Chrham2",false)) { ...
Reply
#6

Quote:
Originally Posted by David.
if(!strfind(playername,"LVC_Chrham2",false)) { ...
Why use strfind and not strcmp? With strfind my name could be 1LVC_Chrham2 and it would return true.
Reply
#7

Quote:
Originally Posted by Cezar
Your Code is correct except one thing is missing (Ben^ : strcmp returns 0 if the strings match. He did it correctly .).

Now what you did wrong is the you forgot to use "GetPlayerName" function. You created a string were to store it but you forgot to actually use the function. A small correction and it should work:

pawn Код:
public OnPlayerRequestSpawn(playerid)
{
  new playername[MAX_PLAYER_NAME];
  GetPlayerName(playerid, playername, sizeof(playername));
  if(gTeam[playerid]==Team_Cops) // POLICE
    {
      if(strcmp(playername,"LVC_Chrham2",false)==0)
      {
        SendClientMessage(playerid,COLOR_BLUE,"Welcome to you, Police Officer! You are now on duty and you must do your best to protect Chrham's City!");
        return 1;
      }
      else
      {
        SendClientMessage(playerid,COLOR_BLUE,"Only cops who have applied at the forums can spawn.");
        SendClientMessage(playerid,COLOR_BLUE,"[url]http://chrhamrpg.one-forum.net/businesses-f6/"[/url]);
        return 0;
        }
    }
  if(gTeam[playerid]==Team_FBI) // FBI
    {
      if(strcmp(playername,"LVC_Chrham2",false)==0)
      {
        SendClientMessage(playerid,COLOR_BLUE,"Welcome to you, FBI Officer! You are now on duty and you must do your best to protect Chrham's City!");
        return 1;
      }
      else
      {
        SendClientMessage(playerid,COLOR_BLUE,"Only FBI Officers who have applied at the forums can spawn.");
        SendClientMessage(playerid,COLOR_BLUE,"[url]http://chrhamrpg.one-forum.net/businesses-f6/"[/url]);
        return 0;
        }
    }
  if(gTeam[playerid]==Team_Army) // ARMY
    {
      if(strcmp(playername,"LVC_Chrham2",false)==0)
      {
        SendClientMessage(playerid,COLOR_BLUE,"Welcome to you guy in the army! You must do your best to protect Chrham's City!");
        return 1;
      }
      else
      {
        SendClientMessage(playerid,COLOR_BLUE,"Only armys who have applied at the forums can spawn.");
        SendClientMessage(playerid,COLOR_BLUE,"[url]http://chrhamrpg.one-forum.net/businesses-f6/"[/url]);
        return 0;
        }
    } else {
    return 1;
    }
}
Other Reference:
https://sampwiki.blast.hk/wiki/Strcmp - Definition of strcmp
https://sampwiki.blast.hk/wiki/GetPlayerName - Definition of GetPlayerName
Uh! It still dont work! Whats wrong
Reply
#8

Any ideas?
Reply
#9

Any ideas?
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)