Help please?
#1

Ok I am having a problem saving teams. I am using the Nazi Zombie TDM's Register script.

I try to get it to save the teams but it won't work when you login you can't choose your faction.

I have tried pTeam, pTeamid, pteam, pteamid.

SCript for /team follows below.

I appreciate any help guys. Thanks in advance.

Код:
	if(strcmp(cmd, "/team", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
		  new tmp[256];
			tmp = strtok(cmdtext, idx);

			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /team [playerid] [teamid]");
				return 1;
			}
			giveplayerid = strval(tmp);
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			if (PlayerInfo[playerid][pAdmin] > 4)
			{
				SendClientMessage(playerid, COLOR_WHITE, "USAGE: /team [playerid] [teamid]");
				return 1;
			}
	 		teamid = strval(tmp);
			if (IsPlayerConnected(giveplayerid))
			{
				GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
				GetPlayerName(playerid, sendername, sizeof(sendername));
				if (teamid > 0 && teamid < 10)
				{
				  SetPlayerTeam(playerid,teamid);
					team[giveplayerid] = teamid;
					SetPlayerHealth(giveplayerid, 0);
					SetPlayerMoney(GetPlayerMoney(giveplayerid)+100);
					SendClientMessage(giveplayerid, COLOR_WHITE,"An Admin has changed your team.");
				}
				else
				{
					SendClientMessage(playerid, COLOR_YELLOW, "Invalid teamid(1-9).");
				}
			}
			else
			{
				format(string, sizeof(string), "%d is not an active player.", giveplayerid);
				SendClientMessage(playerid, COLOR_YELLOW, string);
			}
		}
		else SendClientMessage(playerid, COLOR_YELLOW, "You are not an Admin.");
		return 1;
	}
Reply
#2

Do you save player's team to his userfile also?
Reply
#3

Ya let me get you the rest of the coding.

Код:
static team[MAX_PLAYERS];
Код:
enum pInfo
{
	pPassword[128],
	pRank,
	pExp,
	pKills,
	pDeaths,
	pAdmin,
	pPremium,
	pSaw,
	pCash,
	pMarine,
	pPolice,
	pNemesis,
	pFBI,
	pMuted,
	pLocked,
	pLocal,
	pLevel,
	pInt,
	pJailed,
	pJailTime,
	pTeam,

};
Код:
public OnPlayerRequestSpawn(playerid)
{
	if(team[playerid] == 0)
 	{
		SendClientMessage(playerid,COLOR_RED,"You must select your team before spawning.");
		SendClientMessage(playerid, COLOR_WHITE,"Type /human or /zombie if you do not see the menu.");
		return 0;
	}
	else if(team[playerid] == 0)
  	{
		SendClientMessage(playerid,COLOR_RED,"You must select your team before spawning.");
		SendClientMessage(playerid, COLOR_WHITE,"Type /human or /zombie if you do not see the menu.");
		return 0;
	}
	return 1;
}
Код:
public OnPlayerConnect(playerid)
{
  freq[playerid] = 100000;
  warnings[playerid] = 2;
  team[playerid] = 0;
Код:
new string[64];
	new playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, sizeof(playername));
	format(string, sizeof(string), "Welcome to Prodigy Gaming Zombieland Roleplay %s.",playername);
	SendClientMessage(playerid, COLOR_GREEN,string);

  LastMoney[playerid] = 0;
	CurrentMoney[playerid] = 0;
	PlayerInfo[playerid][pAdmin] = 0;
	PlayerInfo[playerid][pPremium] = 0;
	PlayerInfo[playerid][pSaw] = 0;
	PlayerInfo[playerid][pDeaths] = 0;
	PlayerInfo[playerid][pKills] = 0;
	PlayerInfo[playerid][pExp] = 0;
	PlayerInfo[playerid][pRank] = 0;
	PlayerInfo[playerid][pCash] = 0;
	PlayerInfo[playerid][pMarine] = 0;
	PlayerInfo[playerid][pPolice] = 0;
	PlayerInfo[playerid][pNemesis] = 0;
	PlayerInfo[playerid][pFBI] = 0;
	PlayerInfo[playerid][pMuted] = 0;
	PlayerInfo[playerid][pLocked] = 0;
	PlayerInfo[playerid][pLocal] = 0;
	PlayerInfo[playerid][pLocal] = 255;
	PlayerInfo[playerid][pLevel] = 0;
	PlayerCuffed[playerid] = 0;
 	PlayerCuffedTime[playerid] = 0;
	PlayerInfo[playerid][pInt] = 0;
	PlayerInfo[playerid][pJailed] = 0;
	PlayerInfo[playerid][pJailTime] = 0;
	PlayerInfo[playerid][pTeam] = 0;
  return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
  new Menu:current;
  current = GetPlayerMenu(playerid);
  if(current == mainmenu)
  {
    switch(row)
    {
    	case 0:{
      team[playerid] = 1;
      SendClientMessage(playerid,COLOR_GREEN,"You may now spawn.");
      }
      case 1:{
			team[playerid] = 2;
			SendClientMessage(playerid,COLOR_GREEN,"You may now spawn.");
      }
      case 2:{
				if(GetPlayerTeam(playerid) == 4)
				{
    			team[playerid] = 4;
				SendClientMessage(playerid,COLOR_GREEN,"You may now spawn.");
      	}
				else
				{
				SendClientMessage(playerid,COLOR_RED,"You are not a member of Marine Corps");
				ShowMenuForPlayer(mainmenu, playerid);
				}
			}
  			case 3:{
				if(GetPlayerTeam(playerid) == 3)
				{
		  	team[playerid] = 3;
				SendClientMessage(playerid,COLOR_GREEN,"You may now spawn.");
      		}
				else
				{
				SendClientMessage(playerid,COLOR_RED,"You are not a member of the Enclave");
				ShowMenuForPlayer(mainmenu, playerid);
				}
			}
			case 4:{
				if(GetPlayerTeam(playerid) == 5)
				{
		  	team[playerid] = 5;
				SendClientMessage(playerid,COLOR_GREEN,"You may now spawn.");
      		}
				else
				{
				SendClientMessage(playerid,COLOR_RED,"You are not a member of LSPD.");
				ShowMenuForPlayer(mainmenu, playerid);
				}
 			}
			
    }
  }
So any ideas? if you need more let me know I might have mosre of the coding
Reply
#4

Show OnPlayerDisconnect code.
Reply
#5

Код:
public OnPlayerDisconnect(playerid, reason)
{
  OnPlayerUpdate(playerid);
  gPlayerLogged[playerid] = 0;
  MidoStreamDisconnect(playerid);
	return 1;
}
There you go.
Reply
#6

And now OnPlayerUpdate
Reply
#7

Код:
public OnPlayerUpdate(playerid)
{
	if(IsPlayerConnected(playerid))
	{
		if(gPlayerLogged[playerid])
		{
			new string3[32];
			new pname3[MAX_PLAYER_NAME];
			GetPlayerName(playerid, pname3, sizeof(pname3));
			format(string3, sizeof(string3), "%s.ini", pname3);
			new File: pFile = fopen(string3, io_write);
			if (pFile)
			{
				new var[32];
				format(var, 32, "%s\n", PlayerInfo[playerid][pPassword]);fwrite(pFile, var);
				fclose(pFile);
				new File: hFile = fopen(string3, io_append);
				PlayerInfo[playerid][pCash] = GetPlayerMoney(playerid);
				format(var, 32, "Rank=%d\n",PlayerInfo[playerid][pRank]);fwrite(hFile, var);
				format(var, 32, "Exp=%d\n",PlayerInfo[playerid][pExp]);fwrite(hFile, var);
				format(var, 32, "Kills=%d\n",PlayerInfo[playerid][pKills]);fwrite(hFile, var);
				format(var, 32, "Deaths=%d\n",PlayerInfo[playerid][pDeaths]);fwrite(hFile, var);
				format(var, 32, "Admin=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
        format(var, 32, "Premium=%d\n",PlayerInfo[playerid][pPremium]);fwrite(hFile, var);
				format(var, 32, "pG=%d\n",PlayerInfo[playerid][pSaw]);fwrite(hFile, var);
				format(var, 32, "Money=%d\n",PlayerInfo[playerid][pCash]);fwrite(hFile, var);
				format(var, 32, "Police=%d\n",PlayerInfo[playerid][pPolice]);fwrite(hFile, var);
				format(var, 32, "Marine=%d\n",PlayerInfo[playerid][pMarine]);fwrite(hFile, var);
				format(var, 32, "Nemesis=%d\n",PlayerInfo[playerid][pNemesis]);fwrite(hFile, var);
				format(var, 32, "FBI=%d\n",PlayerInfo[playerid][pFBI]);fwrite(hFile, var);
				format(var, 32, "Muted=%d\n",PlayerInfo[playerid][pMuted]);fwrite(hFile, var);
				format(var, 32, "Locked=%d\n",PlayerInfo[playerid][pLocked]);fwrite(hFile, var);
				format(var, 32, "Local=%d\n",PlayerInfo[playerid][pLocal]);fwrite(hFile, var);
				format(var, 32, "Team=%d\n",PlayerInfo[playerid][pTeam]);fwrite(hFile, var);
				fclose(hFile);
			}
			new string[50];
			new nxtlevel = PlayerInfo[playerid][pRank]+1;
			new costlevel = nxtlevel*rankcost;//1000 for testing purposes
			if (PlayerInfo[playerid][pExp] >= costlevel)
			{
			PlayerInfo[playerid][pRank]++;
			format(string, sizeof(string), "~g~Ranked Up~n~~w~You Are Now Rank %d", nxtlevel);
			PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
			PlayerPlayMusic(playerid);
			GivePlayerMoney(playerid, 10000);
			new rank = PlayerInfo[playerid][pRank];
			SetPlayerScore(playerid, rank);
			}
		}
	}
	return 1;
}
Lol anything else ?
Reply
#8

Change
pawn Код:
format(var, 32, "Team=%d\n",PlayerInfo[playerid][pTeam]);fwrite(hFile, var);
to
pawn Код:
format(var, 32, "Team=%d\n",team[playerid]);fwrite(hFile, var);
And you have to change the same thing on login.
Reply
#9

OK then how do I get /team to work it when you set their team it saves it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)