SA-MP Forums Archive
ForceClassSelection - 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)
+--- Thread: ForceClassSelection (/showthread.php?tid=637341)



ForceClassSelection - SeifGeny - 12.07.2017

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;
}



Re: ForceClassSelection - DTV - 13.07.2017

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;
}



Re: ForceClassSelection - GuilhermeNunes - 13.07.2017

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;




Re: ForceClassSelection - SeifGeny - 13.07.2017

I want to make it in one cmd


Re: ForceClassSelection - GuilhermeNunes - 13.07.2017

Has no way ...


Re: ForceClassSelection - Loinal - 13.07.2017

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


Re: ForceClassSelection - GuilhermeNunes - 13.07.2017

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


Re: ForceClassSelection - Abagail - 13.07.2017

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