08.08.2012, 18:42
I am making a Team Death Match Mode and cuz i am new to SAMP scripting i want to ask you about the method i am working on , IS IS GOOD OR NOT
0- Defines
1- Here is the Team Select Dialog --
2- Dialog Response
Player Class Set
OnPlayerSpawn
So is this a good way for TDM ?
0- Defines
pawn Код:
//Teams
static gTeam[MAX_PLAYERS];
#define TEAM_USA 0
#define TEAM_RUSSIA 1
#define TEAM_EGYPT 2
#define TEAM_IRAQ 3
#define TEAM_JAPAN 4
#define TEAM_CHINA 5
#define TEAM_ITALY 6
//EndTeams
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
ShowPlayerDialog( playerid, DIALOG_SPAWN_CLASS, DIALOG_STYLE_LIST, "{ffffff}Pick A Nation", "{d60f0f}Russia\n{d46317}Egypt\n{d4c917}Iraq\n{1767d4}United States\n{7f0fd6}China\n{93e4e9}Japan\n{47d60f}Italy", "Select", "Cancel" );
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_SPAWN_CLASS: //SPAWNING DIALOG
{
if( response )
{
switch( listitem )
{
case 0: // Class 1
{
SetPlayerClass(playerid, 0);
SpawnPlayer(playerid);
}
case 1: //class 2
{
SetPlayerClass(playerid, 1);
SpawnPlayer(playerid);
}
case 2: // class 3
{
SetPlayerClass(playerid, 2);
SpawnPlayer(playerid);
}
case 3: // class 4
{
SetPlayerClass(playerid, 3);
SpawnPlayer(playerid);
}
case 4: // class 5
{
SetPlayerClass(playerid, 4);
SpawnPlayer(playerid);
}
case 5: // class 6
{
SetPlayerClass(playerid, 5);
SpawnPlayer(playerid);
}
case 6: // class 7
{
SetPlayerClass(playerid, 6);
SpawnPlayer(playerid);
}
}
}
else
{
ShowPlayerDialog( playerid, DIALOG_SPAWN_CLASS, DIALOG_STYLE_LIST, "{ffffff}Pick A Nation -REQUIRED-", "{d60f0f}Russia\n{d46317}Egypt\n{d4c917}Iraq\n{1767d4}United States\n{7f0fd6}China\n{93e4e9}Japan\n{47d60f}Italy", "Select", "Cancel" );
}
}
}
return 1;
}
pawn Код:
SetPlayerClass(playerid, classid)
{
if(classid == 0) {
gTeam[playerid] = TEAM_RUSSIA;
}
else if(classid == 1) {
gTeam[playerid] = TEAM_EGYPT;
}
else if(classid == 2) {
gTeam[playerid] = TEAM_IRAQ;
}
else if(classid == 3) {
gTeam[playerid] = TEAM_USA;
}
else if(classid == 4) {
gTeam[playerid] = TEAM_CHINA;
}
else if(classid == 5) {
gTeam[playerid] = TEAM_JAPAN;
}
else if(classid == 6) {
gTeam[playerid] = TEAM_ITALY;
}
}
pawn Код:
public OnPlayerSpawn(playerid)
{
if(gTeam[playerid] == TEAM_RUSSIA) {
SetRandomRUSSIAPos(playerid);
SetPlayerSkin(playerid, 50);
}
else if(gTeam[playerid] == TEAM_EGYPT) {
SetRandomEGYPTPos(playerid);
SetPlayerSkin(playerid, 48);
}
else if(gTeam[playerid] == TEAM_IRAQ) {
SetRandomIRAQPos(playerid);
SetPlayerSkin(playerid, 47);
}
else if(gTeam[playerid] == TEAM_USA) {
SetRandomUSAPos(playerid);
SetPlayerSkin(playerid, 46);
}
else if(gTeam[playerid] == TEAM_CHINA) {
SetRandomCHINAPos(playerid);
SetPlayerSkin(playerid, 45);
}
else if(gTeam[playerid] == TEAM_JAPAN) {
SetRandomJAPANPos(playerid);
SetPlayerSkin(playerid, 44);
}
else if(gTeam[playerid] == TEAM_ITALY) {
SetRandomITALYPos(playerid);
SetPlayerSkin(playerid, 43);
}
return 1;
}