09.05.2015, 12:27
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
But I managed to do without the standard dialog. Who knows stable method?
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(playerid, classid)
{
printf("call OnPlayerRequestClass");
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(playerid, playerid+1);
if(GetPlayerGameStat(playerid) != GAMESTAT_FIRSTRESPAWN) {
SetPlayerGameStat(playerid, GAMESTAT_REQUESTCLASS);
TogglePlayerSpectating(playerid, 1);
}
SendClientMessage(playerid, -1, "GAMESTAT: REQUESTCLASS");
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SetPlayerGameStat(playerid,0);
return 1;
}
public OnPlayerSpawn(playerid)
{
SetPlayerPos(playerid, 1378.1815,-834.8283,69.9717);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(GetPlayerGameStat(playerid) == GAMESTAT_INGAME) SendDeathMessageToPlayer(playerid, killerid, playerid, reason);
return 1;
}
public OnPlayerUpdate(playerid)
{
new keys, keyud, keylf;
GetPlayerKeys(playerid, keys, keyud, keylf);
if(GetPlayerGameStat(playerid) == GAMESTAT_REQUESTCLASS) {// && GetPlayerState(playerid) == PLAYER_STATE_SPECTATING) {
SetSpawnInfo(playerid, 0, p_info[playerid][SKIN], 0.0,0.0,0.0, 0.0, 0, 0, 0, 0, 0, 0); //fix: hide bottle,cigarette
TogglePlayerSpectating(playerid, 0);
SetSpawnInfo(playerid, 0, p_info[playerid][SKIN], 0.0,0.0,0.0, 0.0, 0, 0, 0, 0, 0, 0); //fix: hide bottle,cigarette
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);
SendClientMessage(playerid, -1, "GAMESTAT: FIRSTRESPAWN");
SetPlayerGameStat(playerid, GAMESTAT_FIRSTRESPAWN);
return 1;
}
if(GetPlayerGameStat(playerid) == GAMESTAT_FIRSTRESPAWN
&& GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
SetPlayerGameStat(playerid, GAMESTAT_SKINEDITOR);
TogglePlayerControllable(playerid, 0);
SendClientMessage(playerid, -1, "GAMESTAT: SKINEDITOR");
return 1;
}
if(GetPlayerGameStat(playerid) == GAMESTAT_SKINEDITOR) {
if(keys == KEY_SECONDARY_ATTACK) {
SetCameraBehindPlayer(playerid);
TogglePlayerControllable(playerid, 1);
SetPlayerVirtualWorld(playerid, 0);
SetPlayerGameStat(playerid, GAMESTAT_INGAME);
SendClientMessage(playerid, -1, "GAMESTAT: INGAME");
return 1;
}
if(keylf == KEY_LEFT) {
p_info[playerid][SKIN]--;
if(p_info[playerid][SKIN] < 0) p_info[playerid][SKIN] = 299;
SetPlayerSkin(playerid, p_info[playerid][SKIN]);
} else if(keylf == KEY_RIGHT) {
p_info[playerid][SKIN]++;
if(p_info[playerid][SKIN] > 299) p_info[playerid][SKIN] = 0;
SetPlayerSkin(playerid, p_info[playerid][SKIN]);
}
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/kill", cmdtext, true, 10) == 0)
{
SetPlayerHealth(playerid, 0);
return 1;
}
return 0;
}