ForceClassSelection
#1

I got this code but it doesn't Force the player to class selection, it just kills him

Код:
CMD:kill(playerid, params[])
{
    ForceClassSelection(playerid);
	SetPlayerHealth(playerid, 0);
	GameTextForPlayer(playerid, "You Have been Killed", 5000, 4);
	return 1;
}
Reply
#2

Taken from https://sampwiki.blast.hk/wiki/ForceClassSelection:

Quote:

The player will not return to class selection until they re-spawn. This can be achieved with TogglePlayerSpectating, as seen in the below example.

Код:
if(!strcmp(cmdtext, "/class", true))
{
    ForceClassSelection(playerid);
    TogglePlayerSpectating(playerid, true);
    TogglePlayerSpectating(playerid, false);
    return 1;
}
Reply
#3

It's killing, why did you put it? SetPlayerHealth (playerid, 0) That is to say you said that it is TO LEAVE WITHOUT LIFE THE PLAYER IN CASE TO KILL

PHP код:
CMD:class(playeridparams[])
{
    
ForceClassSelection(playerid);
    
TogglePlayerSpectating(playeridtrue);
    
TogglePlayerSpectating(playeridfalse);
    return 
1;

PHP код:
CMD:kill(playerid,params[])
{
   
SendClientMessage(playerid, -1"You Have been Killed");
   
SetPlayerHealth(playerid0)
   
GameTextForPlayer(playerid"You Have been Killed"50004);
   return 
1;

Reply
#4

I want to make it in one cmd
Reply
#5

Has no way ...
Reply
#6

Quote:
Originally Posted by SeifGeny
Посмотреть сообщение
I got this code but it doesn't Force the player to class selection, it just kills him

Код:
CMD:kill(playerid, params[])
{
    ForceClassSelection(playerid);
	SetPlayerHealth(playerid, 0);
	GameTextForPlayer(playerid, "You Have been Killed", 5000, 4);
	return 1;
}
try to setplayerhealth to 0 first then force class selection
Reply
#7

Programming is all about logic If you put to kill the player in a cmd that will bring him back to the selection class will have no logic and obvious will have bugs

PHP код:
SetPlayerHealth(playerid0); 
This function says that it is for setar 0 of life in the case kill the player

PHP код:
ForceClassSelection(playerid); 
    
TogglePlayerSpectating(playeridtrue); 
    
TogglePlayerSpectating(playeridfalse); 
This one says that it is to force him to go the selection of

Ie it does not make sense to give 0 of life since the player returning to the selection class will already win 0 of
Reply
#8

Thankfully, death events are succeeded with OnPlayerDeath being called. This allows you to take action whenever a player dies, e.g: setting them through to spawn. If you only want them to go through class selection after using a single command (or other under conditions), you could use variables.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
       // do something
       return true;
}

or:

public OnPlayerDeath(playerid, killerid, reason)
{      
       if(g_pDeathClassSelection[playerid] == true)
       {
               // force the player through class selection
               g_pDeathClassSelection[playerid] = false;
       }
       return true;
}
Reference: https://sampwiki.blast.hk/wiki/OnPlayerDeath
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)