AddPlayerClass by name
#1

I wanted to make a skin for a certain name wich other players can't use. I was wondering if someone could help me out because I searched throught internet and I couldn't find a good one. I want to add this: If a person selects a skin that doesn't belong to him, he gets killed everytime untill he gets back in class selection.

Please help me out.
Reply
#2

Under OnGamemodeInit() add all the player classes.
Then Under OnPlayerRequest Spawn:
Код:
new PlayerName[MAX_PLAYER_NAME], str[128];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
if(!strcmp(playername,"PLAYERNAMEHERE",true)
{ 
  if(GetPlayerSkin(playerid)=="hisskin")
  return 1;
}
else return SendClientMessage(playerid,COLOR,"Please choose another skin");
Reply
#3

I get some errors but I can't find where I have to put the classid... any idea?

warning 217: loose indentation
error 017: undefined symbol "playername"
error 033: array must be indexed (variable "-unknown-")
error 017: undefined symbol "COLOR"
warning 217: loose indentation
warning 204: symbol is assigned a value that is never used: "str"
Reply
#4

Funnily this is the exact same question another guy asked a few minutes ago:

http://forum.sa-mp.com/index.php?topic=173032.0

Here's my code:

Код:
public OnPlayerRequestClass(playerid,classid)
{
  new cmpstr[MAX_PLAYER_NAME];
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 5 && strcmp(cmpstr,"Jay",false))
  {
    SendClientMessage(playerid,COLOR_GREEN,"This skin is only for Jay!");
    return 0;
  }
  return 1;
}
Reply
#5

Quote:
Originally Posted by juice.j
Funnily this is the exact same question another guy asked a few minutes ago:

http://forum.sa-mp.com/index.php?topic=173032.0

Here's my code:

Код:
public OnPlayerRequestClass(playerid,classid)
{
  new cmpstr[MAX_PLAYER_NAME];
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 5 && strcmp(cmpstr,"Jay",false))
  {
    SendClientMessage(playerid,COLOR_GREEN,"This skin is only for Jay!");
    return 0;
  }
  return 1;
}
Hmm iv'e tryed this and it doesn't work it locks all skins in class selection, Unless i done somthing wrong.
Reply
#6

Yeah I saw it and i used it but I get this warning now : warning 225: unreachable code
Reply
#7

This error is not caused by my code, I can compile it just fine
Reply
#8

Somehow its very bugged now...
I used it like this:
Код:
public OnPlayerRequestClass(playerid, classid)
{
	SetupPlayerForClassSelection(playerid,classid);
	SetPlayerTeamFromClass(playerid,classid);
	{
  new cmpstr[MAX_PLAYER_NAME];
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 1 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for Sweet!");
    return 0;
  }

  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 2 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for Big Smoke!");
    return 0;
	}

  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 3 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for Ryder!");
    return 0;
  }
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 4 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for CJ!");
    return 0;
  }
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 5 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for OG Loc!");
    return 0;
  }
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 9 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for Ballas Leader!");
    return 0;
  }
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 14 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for Vagos Leader!");
    return 0;
  }
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 19 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for Cesar Vialpando!");
    return 0;
  }
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 24 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for T-Bone Mendez!");
    return 0;
  }
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 29 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for The SnakeHead!");
    return 0;
  }
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 34 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for Wu Zi Mu!");
    return 0;
  }
  GetPlayerName(playerid, cmpstr, sizeof(cmpstr));
  if(classid == 39 && strcmp(cmpstr,"UnknownName",false))
  {
    SendClientMessage(playerid,TEAM_GROVE_COLOR,"This skin is only for Mafia Leader!");
    return 0;
  }
  return 1;
	}

	if(classid == 0) {
	  GameTextForPlayer(playerid,"~y~]~r~Sean Sweet Johnson",1000,5);
	} else if (classid == 1) {
	  GameTextForPlayer(playerid,"~y~]~r~Melvin Big Smoke Harris",1000,5);
	} else if (classid == 2) {
    GameTextForPlayer(playerid,"~y~]~r~Lance Ryder Wilson",1000,5);
	} else if (classid == 3) {
    GameTextForPlayer(playerid,"~y~]~r~Carl CJ Johnson",1000,5);
	} else if (classid == 4) {
    GameTextForPlayer(playerid,"~y~]~r~Jeffrey OG Loc Cross",1000,5);
	} else if (classid == 5 || classid == 6 || classid == 7 || classid == 8) {
		GameTextForPlayer(playerid,"~g~Grove Street Families",1000,5);
	} else if(classid == 9) {
	  GameTextForPlayer(playerid,"~y~]~r~Los Santos Ballas Leader",1000,5);
	} else if(classid == 10 || classid == 11 || classid == 12 || classid == 13) {
	  GameTextForPlayer(playerid,"~p~Los Santos Ballas",1000,5);
 	} else if(classid == 14) {
	  GameTextForPlayer(playerid,"~y~]~r~Los Santos Vagos Leader",1000,5);
	} else if(classid == 15 || classid == 16 || classid == 17 || classid == 18) {
	  GameTextForPlayer(playerid,"~y~Los Santos Vagos",1000,5);
	} else if(classid == 19) {
	  GameTextForPlayer(playerid,"~y~]~r~Cesar Vialpando",1000,5);
	} else if(classid == 20 || classid == 21 || classid == 22 || classid == 23) {
	  GameTextForPlayer(playerid,"~b~Varrios Los Aztecas",1000,5);
	} else if(classid == 24) {
	  GameTextForPlayer(playerid,"~y~]~r~T-Bone Mendez",1000,5);
	} else if(classid == 25 || classid == 26 || classid == 27 || classid == 28) {
	  GameTextForPlayer(playerid,"~b~La Rifa",1000,5);
	} else if(classid == 29) {
	  GameTextForPlayer(playerid,"~y~]~r~The SnakeHead",1000,5);
	} else if(classid == 30 || classid == 31 || classid == 32 || classid == 33) {
	  GameTextForPlayer(playerid,"~w~Da Nang Boys",1000,5);
	} else if(classid == 34) {
	  GameTextForPlayer(playerid,"~y~]~r~Wu Zi Mu",1000,5);
	} else if(classid == 35 || classid == 36 || classid == 37 || classid == 38) {
	  GameTextForPlayer(playerid,"~h~~l~Triads",1000,5);
	} else if(classid == 39) {
	  GameTextForPlayer(playerid,"~y~]~r~Mafia Leader",1000,5);
	} else if(classid == 40 || classid == 41 || classid == 42 || classid == 43 || classid == 44 || classid == 45) {
	  GameTextForPlayer(playerid,"~r~~h~Mafia",1000,5);
	}


	return 1;
}
Reply
#9

That is soo wrong ;o
Reply
#10

Can you tell me the right way than?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)