SA-MP Forums Archive
ForceClass - 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: ForceClass (/showthread.php?tid=628937)



ForceClass - sscarface - 17.02.2017

SOLVED!


Re: ForceClass - AjaxM - 17.02.2017

Try this!

PHP код:
CMD:force(playerid,params[]) 

           if(
pData[playerid][pAdmin] < 1) return 0
           new 
idJstring[256]; 
           if(
sscanf(params"u"id)) return SendClientMessage(playeridRED"Usage: /force <Player ID>  will force a player to the class selection!"); 
           if(!
IsPlayerConnected(id) || id == INVALID_PLAYER_ID
           { 
               
SendClientMessage(playeridRED"That Player Is Not Connected."); 
               return 
1
           } 
           
ForceClass[id] = 1;  // 'id' not 'playerid'
           
format(Jstring,sizeof(Jstring),"You have forced '%s' to class selection",GetName(id)); 
           
SendClientMessage(playerid,COLOR_ADMIN,Jstring); 
           
format(Jstring,sizeof(Jstring),"Admin '%s' has forced you to class selection",GetName(playerid)); 
           
SendClientMessage(id,COLOR_ADMIN,Jstring); 
           
SetPlayerHealth(id,0); 
           
ForceClassSelection(id); 
           return 
1




Re: ForceClass - X337 - 17.02.2017

Try this:
Код:
public OnPlayerRequestClass(playerid, classid)
{
	if(!ForceClass[playerid] && IsPlayerRegisterd[playerid] == 1) // If player is registerd and forced to class selection by an admin
		SetPlayerSkin(playerid, pData[playerid][pSkin]); // <-- It caused by this code

	SetPlayergTeam(playerid, pData[playerid][pTeam]);
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerColor(playerid, DEATH);
	TogglePlayerSpectating(playerid, 0);
	return 1;
}
You don't need that much if statements.

And also, change
Код:
ForceClass[playerid] = 1;
to
Код:
ForceClass[id] = 1;
as the player that being forced to class selection is "id".

Edit: AjaxM was faster.


Re: ForceClass - sscarface - 17.02.2017

Quote:
Originally Posted by AjaxM
Посмотреть сообщение
Try this!

PHP код:
CMD:force(playerid,params[]) 

           if(
pData[playerid][pAdmin] < 1) return 0
           new 
idJstring[256]; 
           if(
sscanf(params"u"id)) return SendClientMessage(playeridRED"Usage: /force <Player ID>  will force a player to the class selection!"); 
           if(!
IsPlayerConnected(id) || id == INVALID_PLAYER_ID
           { 
               
SendClientMessage(playeridRED"That Player Is Not Connected."); 
               return 
1
           } 
           
ForceClass[id] = 1;  // 'id' not 'playerid'
           
format(Jstring,sizeof(Jstring),"You have forced '%s' to class selection",GetName(id)); 
           
SendClientMessage(playerid,COLOR_ADMIN,Jstring); 
           
format(Jstring,sizeof(Jstring),"Admin '%s' has forced you to class selection",GetName(playerid)); 
           
SendClientMessage(id,COLOR_ADMIN,Jstring); 
           
SetPlayerHealth(id,0); 
           
ForceClassSelection(id); 
           return 
1

Nope


Re: ForceClass - sscarface - 17.02.2017

Quote:
Originally Posted by X337
Посмотреть сообщение
Try this:
Код:
public OnPlayerRequestClass(playerid, classid)
{
	if(!ForceClass[playerid] && IsPlayerRegisterd[playerid] == 1) // If player is registerd and forced to class selection by an admin
		SetPlayerSkin(playerid, pData[playerid][pSkin]); // <-- It caused by this code

	SetPlayergTeam(playerid, pData[playerid][pTeam]);
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerColor(playerid, DEATH);
	TogglePlayerSpectating(playerid, 0);
	return 1;
}
You don't need that much if statements.

And also, change
Код:
ForceClass[playerid] = 1;
to
Код:
ForceClass[id] = 1;
as the player that being forced to class selection is "id".

Edit: AjaxM was faster.
My code doesn't work this way. I have a system where new players can choose skin but once they login and quit then skin will be saved and it will same skin if they re join. So, i m creating a system like a hospital where they can change skin.


Re: ForceClass - X337 - 17.02.2017

Quote:
Originally Posted by sscarface
Посмотреть сообщение
My code doesn't work this way. I have a system where new players can choose skin but once they login and quit then skin will be saved and it will same skin if they re join. So, i m creating a system like a hospital where they can change skin.
My code is same as yours, i just make it shorter and make a fix by allowed player to change their skin after being forced to class selection, like you wanted to.


Re: ForceClass - sscarface - 17.02.2017

Quote:
Originally Posted by X337
Посмотреть сообщение
My code is same as yours, i just make it shorter and make a fix by allowed player to change their skin after being forced to class selection, like you wanted to.
Tried and not working.