[Question/SRV 0.3.7] Is there a way to bypass OnPlayerRequestClass?
#1

I appeal to the people who know it

Question: Is there a way to bypass skin selection dialog? OnPlayerRequestClass(playerid, classid) directly to OnPlayerSpawn(playerid)?

I found another way but it works with a bug
I would like something better

Bugs my method:
1. Repeated pressing F4 function starts to always make callback OnPlayerRequestClass();
2. Sometimes there is a character in the hands of a bottle or a cigarette

PHP код:
/**
 * GAMEMODE : game (lite version)
 * revision : 0.1 @9 may 2015
 * author   : fERO aka Logofero
 **/
#define GAMEMODE_NAME "game (lite version)"
#include <a_samp>
#define MAX_MSG_SIZE (256)
#define COLOR_DEFAULT (0xAAAAAAFF)
#define GAMESTAT_NONE (0)
#define GAMESTAT_REQUESTCLASS (1)
#define GAMESTAT_FIRSTRESPAWN (2)
#define GAMESTAT_SKINEDITOR (3)
#define GAMESTAT_INGAME (4)
enum e_p_info {
    
GAMESTAT,
    
SKIN,
    
DELAYJOIN
}
new 
p_info[MAX_PLAYERS][e_p_info];
#define SetPlayerGameStat(%1,%2)     p_info[%1][GAMESTAT]=%2
#define GetPlayerGameStat(%1)         p_info[%1][GAMESTAT]
main()
{
    print(
"\n----------------------------------");
    
printf(" Gamemode '%s' loaded",GAMEMODE_NAME);
    print(
"----------------------------------\n");
}
public 
OnGameModeInit()
{
    
SetGameModeText(GAMEMODE_NAME);
    return 
1;
}
public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
printf("call OnPlayerRequestClass");
    
SetPlayerPos(playerid1378.1815,-834.8283,69.9717);
    
SetPlayerFacingAngle(playerid351.9014);
    
SetPlayerCameraPos(playerid1378.0965,-831.4299,70.2528);
    
SetPlayerCameraLookAt(playerid1378.1815,-834.8283,70.2528);
    
SetPlayerVirtualWorld(playeridplayerid+1);
    if(
GetPlayerGameStat(playerid) != GAMESTAT_FIRSTRESPAWN) {
        
SetPlayerGameStat(playeridGAMESTAT_REQUESTCLASS);
        
TogglePlayerSpectating(playerid1);
    }    
    
SendClientMessage(playerid, -1"GAMESTAT: REQUESTCLASS");
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
SetPlayerGameStat(playerid,0);
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    
SetPlayerPos(playerid1378.1815,-834.8283,69.9717);
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
GetPlayerGameStat(playerid) == GAMESTAT_INGAMESendDeathMessageToPlayer(playeridkilleridplayeridreason);
    return 
1;
}
public 
OnPlayerUpdate(playerid)
{
    new  
keyskeyudkeylf;
    
GetPlayerKeys(playeridkeyskeyudkeylf);
    if(
GetPlayerGameStat(playerid) == GAMESTAT_REQUESTCLASS) {// && GetPlayerState(playerid) == PLAYER_STATE_SPECTATING) {
        
        
SetSpawnInfo(playerid0p_info[playerid][SKIN], 0.0,0.0,0.00.0000000); //fix: hide bottle,cigarette
        
TogglePlayerSpectating(playerid0);
        
SetSpawnInfo(playerid0p_info[playerid][SKIN], 0.0,0.0,0.00.0000000); //fix: hide bottle,cigarette
        
SetPlayerPos(playerid1378.1815,-834.8283,69.9717);
        
SetPlayerFacingAngle(playerid351.9014);
        
SetPlayerCameraPos(playerid1378.0965,-831.4299,70.2528);
        
SetPlayerCameraLookAt(playerid1378.1815,-834.8283,70.2528);
        
SendClientMessage(playerid, -1"GAMESTAT: FIRSTRESPAWN");
        
SetPlayerGameStat(playeridGAMESTAT_FIRSTRESPAWN);
        return 
1;   
    }
    
    if(
GetPlayerGameStat(playerid) == GAMESTAT_FIRSTRESPAWN
    
&& GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
        
SetPlayerGameStat(playeridGAMESTAT_SKINEDITOR);
        
TogglePlayerControllable(playerid0);    
        
SendClientMessage(playerid, -1"GAMESTAT: SKINEDITOR");
        return 
1;
    }
    
    if(
GetPlayerGameStat(playerid) == GAMESTAT_SKINEDITOR) {
        if(
keys == KEY_SECONDARY_ATTACK) {
            
SetCameraBehindPlayer(playerid);
            
TogglePlayerControllable(playerid1);
            
SetPlayerVirtualWorld(playerid0);
            
SetPlayerGameStat(playeridGAMESTAT_INGAME);
            
SendClientMessage(playerid, -1"GAMESTAT: INGAME");
            return 
1;
        }
        if(
keylf == KEY_LEFT) {
            
p_info[playerid][SKIN]--;
            if(
p_info[playerid][SKIN] < 0p_info[playerid][SKIN] = 299;
            
SetPlayerSkin(playeridp_info[playerid][SKIN]);
        } else if(
keylf == KEY_RIGHT) {
            
p_info[playerid][SKIN]++;
            if(
p_info[playerid][SKIN] > 299p_info[playerid][SKIN] = 0;
            
SetPlayerSkin(playeridp_info[playerid][SKIN]);
        }
    }
    return 
1;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/kill"cmdtexttrue10) == 0)
    {
          
SetPlayerHealth(playerid0);
        return 
1;
    }
    return 
0;

But I managed to do without the standard dialog. Who knows stable method?
Reply
#2

there are countless threads on this

http://forum.sa-mp.com/search.php?searchid=9439758
Reply
#3

Quote:
Originally Posted by TakeiT
Посмотреть сообщение
there are countless threads on this

http://forum.sa-mp.com/search.php?searchid=9439758
Thank you

I found a method and updated its script. It works!
Anyone who has faced the same can use my example:
PHP код:
/**
 * GAMEMODE : game (lite version)
 * revision : 0.1 @9 may 2015
 * author   : fERO aka Logofero
 **/
#define GAMEMODE_NAME "game (lite version)"
#include <a_samp>
#define MAX_MSG_SIZE (256)
#define COLOR_DEFAULT (0xAAAAAAFF)
#define GAMESTAT_NONE (0)
#define GAMESTAT_REQUESTCLASS (1)
#define GAMESTAT_SKINEDITOR (2)
#define GAMESTAT_INGAME (3)
enum e_p_info {
    
GAMESTAT,
    
SKIN
}
new 
p_info[MAX_PLAYERS][e_p_info];
#define SetPlayerGameStat(%1,%2)     p_info[%1][GAMESTAT]=%2
#define GetPlayerGameStat(%1)         p_info[%1][GAMESTAT]
main()
{
    print(
"\n----------------------------------");
    
printf(" Gamemode '%s' loaded",GAMEMODE_NAME);
    print(
"----------------------------------\n");
}
public 
OnGameModeInit()
{
    
SetGameModeText(GAMEMODE_NAME);
    return 
1;
}
public 
OnGameModeExit()
{
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
//SetPlayerPos(playerid, 1378.1815,-834.8283,69.9717);
    //SetPlayerFacingAngle(playerid, 351.9014);
    //SetPlayerCameraPos(playerid, 1378.0965,-831.4299,70.2528);
    //SetPlayerCameraLookAt(playerid, 1378.1815,-834.8283,70.2528);
    
SetPlayerVirtualWorld(playeridplayerid+1);
    
SetSpawnInfo(playerid0p_info[playerid][SKIN], 0.0,0.0,0.00.0000000);
    
SpawnPlayer(playerid);
    
SetPlayerGameStat(playeridGAMESTAT_REQUESTCLASS);
    
SendClientMessage(playerid, -1"GAMESTAT: REQUESTCLASS");
    return 
1;
}
public 
OnPlayerDisconnect(playeridreason)
{
    
SetPlayerGameStat(playerid,0);
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    
SetPlayerPos(playerid1378.1815,-834.8283,69.9717);
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason)
{
    if(
GetPlayerGameStat(playerid) == GAMESTAT_INGAMESendDeathMessageToPlayer(playeridkilleridplayeridreason);
    return 
1;
}
public 
OnPlayerUpdate(playerid)
{
    new  
keyskeyudkeylf;
    
GetPlayerKeys(playeridkeyskeyudkeylf);
    if(
GetPlayerGameStat(playerid) == GAMESTAT_REQUESTCLASS) {
        
SetPlayerPos(playerid1378.1815,-834.8283,69.9717);
        
SetPlayerFacingAngle(playerid351.9014);
        
SetPlayerCameraPos(playerid1378.0965,-831.4299,70.2528);
        
SetPlayerCameraLookAt(playerid1378.1815,-834.8283,70.2528);
        
SetSpawnInfo(playerid0p_info[playerid][SKIN], 0.0,0.0,0.00.0000000);
        
SetPlayerGameStat(playeridGAMESTAT_SKINEDITOR);
        
TogglePlayerControllable(playerid0);
        
SendClientMessage(playerid, -1"GAMESTAT: SKINEDITOR");
        return 
1;
    }
    
    if(
GetPlayerGameStat(playerid) == GAMESTAT_SKINEDITOR) {
        if(
keys == KEY_SECONDARY_ATTACK) {
            
SetCameraBehindPlayer(playerid);
            
TogglePlayerControllable(playerid1);
            
SetPlayerVirtualWorld(playerid0);
            
SetPlayerGameStat(playeridGAMESTAT_INGAME);
            
SendClientMessage(playerid, -1"GAMESTAT: INGAME");
            return 
1;
        }
        if(
keylf == KEY_LEFT) {
            
p_info[playerid][SKIN]--;
            if(
p_info[playerid][SKIN] < 0p_info[playerid][SKIN] = 299;
            
SetPlayerSkin(playeridp_info[playerid][SKIN]);
            
        } else if(
keylf == KEY_RIGHT) {
            
p_info[playerid][SKIN]++;
            if(
p_info[playerid][SKIN] > 299p_info[playerid][SKIN] = 0;
            
SetPlayerSkin(playeridp_info[playerid][SKIN]);
            
        }
    }
    return 
1;
}
public 
OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/kill"cmdtexttrue10) == 0)
    {
          
SetPlayerHealth(playerid0);
        return 
1;
    }
    return 
0;

Question decided.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)