#define MAX_GAMES (500)
#define MAX_CLASSES (6)
// Game Mode Types
#define GAME_TDM (1)
#define GAME_LMS (2)
#define GAME_RACE (3)
#define GAME_TAKEOVER (4)
#define GAME_STEALING (5)
#define GAME_ZOMBIE (6)
#define GAME_DM (7)
#define GAME_FALLOUT (8)
#define GAME_BOMBING (9)
enum GameInfo
{
gName[32],
gMode,
gRoundTime,
gSkin[MAX_CLASSES],
Float:gSkinX[MAX_CLASSES],
Float:gSkinY[MAX_CLASSES],
Float:gSkinZ[MAX_CLASSES],
Float:gSkinA[MAX_CLASSES],
gSkinInt[MAX_CLASSES],
gSkinVW[MAX_CLASSES],
gTotalClass
};
new
gInfo[MAX_GAMES][GameInfo],
gGames,
currGame,
currSkin[MAX_PLAYERS]
;
stock CreateGame(name[], mode, time)
{
if(gGames >= MAX_GAMES)
return printf("* Can't create a new game, Has reached the (%d) limit.", MAX_GAMES);
gGames ++;
format(gInfo[gGames][gName], 32, name);
gInfo[gGames][gMode] = mode;
gInfo[gGames][gRoundTime] = time;
gInfo[gGames][gTotalClass] = 0;
for(new i; i < MAX_CLASSES; i++)
{
gInfo[gGames][gSkin][i] = -1;
gInfo[gGames][gSkinX][i] = -1;
gInfo[gGames][gSkinY][i] = -1;
gInfo[gGames][gSkinZ][i] = -1;
gInfo[gGames][gSkinA][i] = -1;
gInfo[gGames][gSkinInt][i] = -1;
gInfo[gGames][gSkinVW][i] = -1;
}
return gGames;
}
stock AddPlayerClasses(gameid, skinid, Float:x, Float:y, Float:z, Float:a, interior, world)
{
if(gInfo[gameid][gTotalClass] >= MAX_CLASSES)
return printf("* Can't add new classes, Has reached the (%d) limit.", MAX_CLASSES);
gInfo[gameid][gSkin][gInfo[gameid][gTotalClass]] = skinid;
gInfo[gameid][gSkinX][gInfo[gameid][gTotalClass]] = x;
gInfo[gameid][gSkinY][gInfo[gameid][gTotalClass]] = y;
gInfo[gameid][gSkinZ][gInfo[gameid][gTotalClass]] = z;
gInfo[gameid][gSkinA][gInfo[gameid][gTotalClass]] = a;
gInfo[gameid][gSkinInt][gInfo[gameid][gTotalClass]] = interior;
gInfo[gameid][gSkinVW][gInfo[gameid][gTotalClass]] = world;
return gInfo[gameid][gTotalClass] ++;
}
public OnGameModeInit()
{
SetGameModeText("Minigames v0.01");
AddPlayerClass(0, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0, 0, 0, 0, 0);
////////////////////////////////////////////////////////////////////////////
CreateGame("Militia Forest", GAME_TDM, 300);
// Green Team
AddPlayerClasses(1, 3, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0);
AddPlayerClasses(1, 133, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0);
AddPlayerClasses(1, 191, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0);
// Blue Team
AddPlayerClasses(1, 285, 1697.8439, -3198.1306, 18.4751, 184.9018, 0, 0);
printf("Total Class for %d: %d", 1, gInfo[1][gTotalClass]);
currGame = 1;
////////////////////////////////////////////////////////////////////////////
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
currSkin[playerid] ++;
if(gInfo[currGame][gTotalClass] >= currSkin[playerid])
{
currSkin[playerid] = 1;
}
SetPlayerSkin(playerid, gInfo[currGame][gSkin][currSkin[playerid]]);
SetPlayerPos(playerid, 2495.0449, 2773.0566, 10.8158);
SetPlayerFacingAngle(playerid, 88.0);
SetPlayerCameraPos(playerid, 2490.9556, 2773.1326, 10.7968);
SetPlayerCameraLookAt(playerid, 2495.0449, 2773.0566, 10.8158);
PlayerPlaySound(playerid, 1068, 2495.0449, 2773.0566, 10.8158);
switch(random(5))
{
case 0: ApplyAnimation(playerid, "DANCING", "dnce_M_a", 4.1, 1, 0, 0, 0, 0);
case 1: ApplyAnimation(playerid, "DANCING", "dnce_M_b", 4.1, 1, 0, 0, 0, 0);
case 2: ApplyAnimation(playerid, "DANCING", "dnce_M_c", 4.1, 1, 0, 0, 0, 0);
case 3: ApplyAnimation(playerid, "DANCING", "dnce_M_d", 4.1, 1, 0, 0, 0, 0);
case 4: ApplyAnimation(playerid, "DANCING", "dnce_M_e", 4.1, 1, 0, 0, 0, 0);
}
return 1;
}
if(gInfo[currGame][gTotalClass] >= currSkin[playerid])
{
currSkin[playerid] = 1;
}
if(currSkin[playerid] >= gInfo[currGame][gTotalClass])
{
currSkin[playerid] = 1;
}
#include a_samp
#define MAX_GAMES (500)
#define MAX_CLASSES (6)
// Game Mode Types
#define GAME_TDM (1)
#define GAME_LMS (2)
#define GAME_RACE (3)
#define GAME_TAKEOVER (4)
#define GAME_STEALING (5)
#define GAME_ZOMBIE (6)
#define GAME_DM (7)
#define GAME_FALLOUT (8)
#define GAME_BOMBING (9)
enum GameInfo
{
gName[32],
gMode,
gRoundTime,
gSkin[MAX_CLASSES],
Float:gSkinX[MAX_CLASSES],
Float:gSkinY[MAX_CLASSES],
Float:gSkinZ[MAX_CLASSES],
Float:gSkinA[MAX_CLASSES],
gSkinInt[MAX_CLASSES],
gSkinVW[MAX_CLASSES],
gTotalClass
};
new
gInfo[MAX_GAMES][GameInfo],
gGames,
currGame,
currSkin[MAX_PLAYERS]
;
stock CreateGame(name[], mode, time)
{
if(gGames >= MAX_GAMES)
return printf("* Can't create a new game, Has reached the (%d) limit.", MAX_GAMES);
gGames ++;
format(gInfo[gGames][gName], 32, name);
gInfo[gGames][gMode] = mode;
gInfo[gGames][gRoundTime] = time;
gInfo[gGames][gTotalClass] = 0;
for(new i; i < MAX_CLASSES; i++)
{
gInfo[gGames][gSkin][i] = -1;
gInfo[gGames][gSkinX][i] = -1;
gInfo[gGames][gSkinY][i] = -1;
gInfo[gGames][gSkinZ][i] = -1;
gInfo[gGames][gSkinA][i] = -1;
gInfo[gGames][gSkinInt][i] = -1;
gInfo[gGames][gSkinVW][i] = -1;
}
return gGames;
}
stock AddPlayerClasses(gameid, skinid, Float:x, Float:y, Float:z, Float:a, interior, world)
{
if(gInfo[gameid][gTotalClass] >= MAX_CLASSES)
return printf("* Can't add new classes, Has reached the (%d) limit.", MAX_CLASSES);
gInfo[gameid][gSkin][gInfo[gameid][gTotalClass]] = skinid;
gInfo[gameid][gSkinX][gInfo[gameid][gTotalClass]] = x;
gInfo[gameid][gSkinY][gInfo[gameid][gTotalClass]] = y;
gInfo[gameid][gSkinZ][gInfo[gameid][gTotalClass]] = z;
gInfo[gameid][gSkinA][gInfo[gameid][gTotalClass]] = a;
gInfo[gameid][gSkinInt][gInfo[gameid][gTotalClass]] = interior;
gInfo[gameid][gSkinVW][gInfo[gameid][gTotalClass]] = world;
return gInfo[gameid][gTotalClass] ++;
}
public OnGameModeInit()
{
SetGameModeText("Minigames v0.01");
AddPlayerClass(0, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0, 0, 0, 0, 0);
AddPlayerClass(1, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0, 0, 0, 0, 0);
AddPlayerClass(2, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0, 0, 0, 0, 0);
////////////////////////////////////////////////////////////////////////////
CreateGame("Militia Forest", GAME_TDM, 300);
// Green Team
AddPlayerClasses(1, 3, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0);
AddPlayerClasses(1, 133, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0);
AddPlayerClasses(1, 191, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0);
// Blue Team
AddPlayerClasses(1, 285, 1697.8439, -3198.1306, 18.4751, 184.9018, 0, 0);
currGame = 1;
////////////////////////////////////////////////////////////////////////////
return 1;
}
new FIRSTTIME[MAX_PLAYERS char], LastSkinZ[MAX_PLAYERS char];
public OnPlayerConnect(playerid)
{
FIRSTTIME[playerid] = 0;
LastSkinZ[playerid] = -1;
}
SetPlayerSkinEx(playerid, &classid)
{
if(classid >= gInfo[currGame][gTotalClass])
{
classid = 0;
}
if(classid < 0)
{
classid = gInfo[currGame][gTotalClass]-1;
}
SetPlayerSkin(playerid, gInfo[currGame][gSkin][classid]);
}
GetSkinEx(LastSkine, newskinz, &nextskinorprev)
{
if(LastSkine != -1)
{
if(LastSkine == 2 && newskinz == 0)
{
nextskinorprev = 1;
}
else if(LastSkine == 0 && newskinz == 2)
{
nextskinorprev = 0;
}
else if(newskinz < LastSkine)
{
nextskinorprev = 0;
}
else if(newskinz > LastSkine)
{
nextskinorprev = 1;
}
}
else
{
nextskinorprev = 1;
}
}
public OnPlayerRequestClass(playerid, classid)
{
new what;
GetSkinEx(LastSkinZ[playerid], classid, what);
LastSkinZ[playerid] = classid;
if(what > 0)
{
if(FIRSTTIME[playerid]) // fisrt time
{
FIRSTTIME[playerid] = 0;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
else
{
currSkin[playerid] ++;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
}
else
{
currSkin[playerid] --;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
SetPlayerPos(playerid, 2495.0449, 2773.0566, 10.8158);
SetPlayerFacingAngle(playerid, 88.0);
SetPlayerCameraPos(playerid, 2490.9556, 2773.1326, 10.7968);
SetPlayerCameraLookAt(playerid, 2495.0449, 2773.0566, 10.8158);
PlayerPlaySound(playerid, 1068, 2495.0449, 2773.0566, 10.8158);
switch(random(5))
{
case 0: ApplyAnimation(playerid, "DANCING", "dnce_M_a", 4.1, 1, 0, 0, 0, 0);
case 1: ApplyAnimation(playerid, "DANCING", "dnce_M_b", 4.1, 1, 0, 0, 0, 0);
case 2: ApplyAnimation(playerid, "DANCING", "dnce_M_c", 4.1, 1, 0, 0, 0, 0);
case 3: ApplyAnimation(playerid, "DANCING", "dnce_M_d", 4.1, 1, 0, 0, 0, 0);
case 4: ApplyAnimation(playerid, "DANCING", "dnce_M_e", 4.1, 1, 0, 0, 0, 0);
}
return 1;
}
PHP код:
PHP код:
however this is how you could've done it. with this system players will be able to go to previous skin not only next. PHP код:
|
AddPlayerClass(0, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0, 0, 0, 0, 0);
AddPlayerClass(1, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0, 0, 0, 0, 0);
AddPlayerClass(2, 1699.9644, -3488.9009, 20.7700, 353.1400, 0, 0, 0, 0, 0, 0);
GetSkinEx(LastSkine, newskinz, &nextskinorprev)
{
if(LastSkine != -1)
{
if(LastSkine == 2 && newskinz == 0)
{
nextskinorprev = 1;
}
else if(LastSkine == 0 && newskinz == 2)
{
nextskinorprev = 0;
}
else if(newskinz < LastSkine)
{
nextskinorprev = 0;
}
else if(newskinz > LastSkine)
{
nextskinorprev = 1;
}
}
else
{
nextskinorprev = 1;
}
}
Sorry I have been gone for 2 days, btw. The code seems to work fine without any errors or what so ever from CrashDetector but I have noticed that I have to press the next button 3-4 times to get to the next skin (The next skin for example currently I have class #1 which is 3, I suppose to have class #2. But it skipped to class #4, SWAT skin)
|
are you sure? did you made any changes on it? because I just tested it and its working perfectly...
|
new what;
GetSkinEx(LastSkinZ[playerid], classid, what);
LastSkinZ[playerid] = classid;
if(what > 0)
{
if(!firstTime[playerid])
{
firstTime[playerid] = 0;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
else
{
currSkin[playerid] ++;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
}
else
{
currSkin[playerid] --;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
With my spawn system I hit issues regarding one of the callbacks spamming, in particular OnPlayerRequestSpawn. I had to put a cooldown on it to make it not fire things multiple times.
|
new what;
GetSkinEx(LastSkinZ[playerid], classid, what);
LastSkinZ[playerid] = classid;
if(what > 0)
{
if(!firstTime[playerid])
{
firstTime[playerid] = 0;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
else
{
currSkin[playerid] ++;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
}
else
{
currSkin[playerid] --;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
new what;
GetSkinEx(LastSkinZ[playerid], classid, what);
LastSkinZ[playerid] = classid;
if(what > 0)
{
if(!firstTime[playerid])
{
firstTime[playerid] = 1;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
else
{
currSkin[playerid] ++;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
}
else
{
currSkin[playerid] --;
SetPlayerSkinEx(playerid, currSkin[playerid]);
}
So do I have to apply something like I will prevent the players for certain amount of time before they go to previous or next skin (class) OnPlayerRequestClass if I am going to use that callback for my custom class selection?
|