OnPlayerCharacterSelection how to dont let player select character -
memeli11 - 07.05.2013
On Player Character Selection , if this player police , he cant select medical worker's team skin , how can I do it ? or just tell me how to do not let select the character ? tell me just thx ...
Re: OnPlayerCharacterSelection how to dont let player select character -
Yashas - 07.05.2013
Something like this will do
This gets the skin ID and puts it in a switch and the skin ID is checked if it matches,if it does then a check on the players team is done to see if the player can use that skin if not a message is shown.And if he hits Spawn with the wrong skin id a check is once again done on OnPlayerSpawn and is forced a class selection again to select another skin.
Код:
public OnPlayerRequestClass(playerid, classid)
{
TextDrawHideForPlayer(playerid, CSTailText);
TextDrawHideForPlayer(playerid, CSTailExtra);
TextDrawShowForPlayer(playerid,CSScreenText);
PlayerPlaySound(playerid,1183,-86.2111,-224.1556,80.1250);
/* You pos,etc stuff go here*/
PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
switch(PlayerInfo[playerid][Skin])
{
case 280,281,282,283,284,285:
{
if(PlayerInfo[playerid][Team] != COP) return ShowTextMessage(playerid,"You can't use this class");
ShowTextMessage(playerid,"~b~COPS");
//COPS
}
case 275,276:
{
if(PlayerInfo[playerid][Team] != MEDIC) return ShowTextMessage(playerid,"You can't use this class");
ShowTextMessage(playerid,"~p~MEDIC");
//MEDIC
}
case 264,211,217,204,187,26,81,23,82,77,66,30,29,249,224,181,195,194,198,33,197,251:
{
if(PlayerInfo[playerid][Team] != COP) return ShowTextMessage(playerid,"You can't use this class");
ShowTextMessage(playerid,"~w~Civilian");
// CIVIL
}
}
return 1;
}
and OnPlayerSpawn if he presses Spawn with the wrong skin then ForceClassSelection(playerid) and kill the player(I dont know if the kill is required)
Код:
public OnPlayerSpawn(playerid)
{
switch(PlayerInfo[playerid][Skin]
{
case 275,276:
{
if(PlayerInfo[playerid][Team] != MEDIC) { ForceClassSelection(playerid); SetPlayerHealth(0); return 1; }//Not sure if kill is required
}
}
}
There might be much better optimized way, I just gave an idea how it can be done.
Re: OnPlayerCharacterSelection how to dont let player select character -
memeli11 - 07.05.2013
Wait when I test I will give you your rep
Re: OnPlayerCharacterSelection how to dont let player select character -
arakuta - 07.05.2013
Create a per-player variable to store the skin at OnPlayerRequestClass.
At OnPlayerRequestSpawn, check if the skin is enabled for playerid to prevent him from spawn.
pawn Код:
public OnPlayerRequestClass(playerid,classid)
{
pClass[playerid] = classid;
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
if(pClass[playerid] == 11 && GetPlayerScore(playerid) < 1000)
{
SendClientMessage(playerid,-1,"You're too young to be a cop!");
return 0; // It means not spawn, and keep the player at class selection, till he choose a valid class for him.
}
return 1;
}
Re: OnPlayerCharacterSelection how to dont let player select character -
Yashas - 07.05.2013
Quote:
Originally Posted by arakuta
Create a per-player variable to store the skin at OnPlayerRequestClass.
At OnPlayerRequestSpawn, check if the skin is enabled for playerid to prevent him from spawn.
pawn Код:
public OnPlayerRequestClass(playerid,classid) { pClass[playerid] = classid; return 1; }
public OnPlayerRequestSpawn(playerid) { if(pClass[playerid] == 11 && GetPlayerScore(playerid) < 1000) { SendClientMessage(playerid,-1,"You're too young to be a cop!"); return 0; // It means not spawn, and keep the player at class selection, till he choose a valid class for him. } return 1; }
|
Oh return 0 and OnPlayerRequestSpawn

, will update my code too.
Re: OnPlayerCharacterSelection how to dont let player select character -
memeli11 - 07.05.2013
+rep given all ty