SA-MP Forums Archive
gTeam again.. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: gTeam again.. (/showthread.php?tid=218642)



gTeam again.. - ThePwherer - 30.01.2011

I put "PROBLEM" where i have problems in my script. please help. (only 4 errors)
Warning 204: symbol is assigned a value that is never used: "gTeam"
(23) : warning 204: symbol is assigned a value that is never used: "gPlayerClass"
(37) : error 017: undefined symbol "gPlayerClass"
(37) : warning 215: expression has no effect
(37) : error 001: expected token: ";", but found "]"
(37) : error 029: invalid expression, assumed zero
(37) : fatal error 107: too many error messages on one line

Код:
#include <a_samp>

#if defined FILTERSCRIPT

#define TEAM_TERORISTS 0
#define TEAM_CT 1
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

#else

main()
{
	print("\n----------------------------------");
	print(" ........GunGame 1.6 by Aidz........");
	print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
PROBLEM:new gPlayerClass[MAX_PLAYERS];
PROBLEM:new gTeam[MAX_PLAYERS];
  AddPlayerClass( 179, 248.0152,1797.7874,7.4141,355.9538, 22, 200, 0, 0, 0, 0); //Terorist
  AddPlayerClass( 285, 209.4644,1871.6427,13.1470,268.5097, 23, 200, 0, 0, 0, 0); //CT
  return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
PROBLEM:gPlayerClass[playerid] = classid;

  switch (classid) {

	   case 0: 

	    {
      gTeam[playerid] = TEAM_CT;            
	       GameTextForPlayer(playerid, "~b~CounterTerorists", 1000, 6);

	    }
	   case 1: 

	    {
      gTeam[playerid] = TEAM_TERORISTS;
      GameTextForPlayer(playerid, "~r~Terorists", 1000, 6);  
	    }
  }
  //Spawn positions the players will see to spawn.
  SetPlayerPos(playerid, 489.8416,-72.4437,999.2266);
  SetPlayerFacingAngle( playerid, 2.3616 );
  SetPlayerCameraPos(playerid, 491.6849,-72.3607,999.2117);
  SetPlayerCameraLookAt(playerid, 489.8416,-72.4437,999.2266);
  SetPlayerInterior(playerid ,11);
  return 1;
}

public OnPlayerConnect(playerid)
{
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{
  if(gTeam[playerid] == TEAM_CT)
  {
    SetPlayerColor(playerid, color);
  }
  if(gTeam[playerid] == TEAM_TERORISTS)
  {
	     SetPlayerColor(playerid, color);
  }

  

  new string[64], pName[MAX_PLAYER_NAME];
  if(gTeam[playerid] == gTeam[playerid])
  {
	     GetPlayerName(playerid,pNombre,MAX_PLAYER_NAME);
	     format(string,sizeof string,"%s has joined.",pNombre);
  	  SendClientMessageToAll(color, string);
  }

public OnPlayerDeath(playerid, killerid, reason)
{
  SendDeathMessage(killerid, playerid, reason); 
  SetPlayerScore(killerid,(GetPlayerScore(killerid))+1); 
  SetPlayerScore(playerid, -1); 

  

  new string[50];
  format(string, sizeof(string), "~w~pWned");
  GameTextForPlayer(playerid, string, 3000, 2);
  return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(r, 1, cmdtext);  /
  dcmd(radio, 5, cmdtext);
  return 0;
}
dcmd_r(playerid, params[])
{
	new text[256], name[60];
	if(sscanf(params, "s", text)) SendClientMessage(playerid, 0xFFFF00FF, "USE: /r <text>");
	else
	{
	  new string[322];
	  GetPlayerName(playerid, name, 60);
	  format(string, 322, "(%s) (Radio): %s", name, text);
	  for(new i=0;i<MAX_PLAYER;i++)
	  {
	    if(IsPlayerConnected(i))
	    {
	    	if(gTeam[i] == gTeam[playerid])
	    	{
	    	  SendClientMessage(i, 0xFF0080FF, string);
				}
			}
		}
	}
	return 1;
}
  if(!strcmp(cmdtext, "/CTAB", true))
  {
    if (gTeam[playerid] == TEAM_POLICE) 
  	{
     GivePlayerWeapon(playerid, 23, 200);
     GivePlayerWeapon(playerid, 31, 120);
    } else {   
    SendClientMessage(playerid, 0xFF0000FFF, "You are not a CounterTerorist.");
  }
  return 0;  
}



Re: gTeam again.. - Riddick94 - 30.01.2011

Damn.. next time Arrange and optimaze this code!

Код:
#include <a_samp>

#define TEAM_TERORISTS 	0
#define TEAM_CT 		1
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

enum pInfo
{
	pTeam,
	pPlayerClass
};
new PlayerInfo[MAX_PLAYERS][pInfo];

main()
{
	print("\n----------------------------------");
	print(" ........GunGame 1.6 by Aidz........");
	print("----------------------------------\n");
}

public OnGameModeInit()
{
  	AddPlayerClass( 179, 248.0152,1797.7874,7.4141,355.9538, 22, 200, 0, 0, 0, 0); //Terorist
  	AddPlayerClass( 285, 209.4644,1871.6427,13.1470,268.5097, 23, 200, 0, 0, 0, 0); //CT
  	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
PlayerInfo[playerid][pPlayerClass] = classid;

switch (classid)
{
case 0:PlayerInfo[playerid][pTeam] = TEAM_CT, GameTextForPlayer(playerid, "~b~CounterTerorists", 1000, 6);
case 1:PlayerInfo[playerid][pTeam] = TEAM_TERORISTS, GameTextForPlayer(playerid, "~r~Terorists", 1000, 6);
}

//Spawn positions the players will see to spawn.
SetPlayerPos(playerid, 489.8416,-72.4437,999.2266);
SetPlayerFacingAngle( playerid, 2.3616 );
SetPlayerCameraPos(playerid, 491.6849,-72.3607,999.2117);
SetPlayerCameraLookAt(playerid, 489.8416,-72.4437,999.2266);
SetPlayerInterior(playerid ,11);
return 1;
}

public OnPlayerConnect(playerid)
{
	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	return 1;
}

public OnPlayerSpawn(playerid)
{

switch(PlayerInfo[playerid][pTeam])
{
	case 0:SetPlayerColor(playerid, color);
	case 1:SetPlayerColor(playerid, color);
}

new string[64], pName[MAX_PLAYER_NAME];
if(PlayerInfo[playerid][pTeam] == PlayerInfo[playerid][pTeam])
{
	GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
	format(string,sizeof string,"%s has joined.",pName);
	SendClientMessageToAll(color, string);
}
	
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
  SendDeathMessage(killerid, playerid, reason);
  SetPlayerScore(killerid,(GetPlayerScore(killerid))+1);
  SetPlayerScore(playerid, -1);



  new string[50];
  format(string, sizeof(string), "~w~pWned");
  GameTextForPlayer(playerid, string, 3000, 2);
  return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(r, 1, cmdtext);
dcmd(radio, 5, cmdtext);
dcmd(ctab, 4, cmdtext);
return 0;
}

dcmd_radio(playerid,params[])return dcmd_r(playerid,params);
dcmd_r(playerid, params[])
{
	new text[256], name[60];
	if(sscanf(params, "s", text)) SendClientMessage(playerid, 0xFFFF00FF, "USE: /r <text>");
	else
	{
	  new string[322];
	  GetPlayerName(playerid, name, 60);
	  format(string, 322, "(%s) (Radio): %s", name, text);
	  for(new i=0;i<MAX_PLAYERS;i++)
	  {
	    if(IsPlayerConnected(i))
	    {
	    	if(PlayerInfo[i][pTeam] == PlayerInfo[playerid][pTeam])
	    	{
	    	  SendClientMessage(i, 0xFF0080FF, string);
			}
		}
	}
	}
	return 1;
}


dcmd_ctab(playerid, params[])
{
#pragma unused params
if (!PlayerInfo[playerid][pTeam] == TEAM_POLICE)return SendClientMessage(playerid, 0xFF0000FFF, "You are not a CounterTerorist.");
GivePlayerWeapon(playerid, 23, 200);
GivePlayerWeapon(playerid, 31, 120);
return 0;
}
You need to define color, sscanf and TEAM_POLICE.

P.S
What the fuck is that?! "[", and dcmd(radio, 5, cmdtext); / ?! Use ZCMD it's better than this. And you doesn't need that:
Код:
#if defined FILTERSCRIPT
#else
#endif
And do not create a 'new' in OnGameModeInit.