gang system
#1

I have create gang but when I logout from server it not automatic save

who can write something about this problem?

Thx,sir
Reply
#2

learn english, and this is not a forum for script requests...
Reply
#3

Alright I try^^
I have the same problem with my "/gang create" command and I created a file which saves the gang into a file
but I don't know how to load the gang from the file...

Код:
	new sendername[MAX_PLAYER_NAME];
	new giveplayer[MAX_PLAYER_NAME];
	new giveplayerid;
  //------------------- /gang

	if(strcmp(cmd, "/gang", true) == 0) {
	  new gangcmd, gangnum;
		tmp = strtok(cmdtext, idx);

		giveplayerid = strval(tmp);

		if(strcmp(tmp, "create", true)==0)
		  gangcmd = 1;
		else if(strcmp(tmp, "invite", true)==0)
		  gangcmd = 2;
		else if(strcmp(tmp, "join", true)==0)
		  gangcmd = 3;
		else if(strcmp(tmp, "leave", true)==0)
		  gangcmd = 4;

		tmp = strtok(cmdtext, idx);
		if(gangcmd < 3 && !strlen(tmp)) {
		  if(gangcmd==0)
				SendClientMessage(playerid, 0x83BFBFFF, "Type /ganghelp for gangcommands.");
			else if(gangcmd==1)
				SendClientMessage(playerid, 0x83BFBFFF, "Type: /gang create [Name]");
			else if(gangcmd==2)
				SendClientMessage(playerid, 0x83BFBFFF, "Type: /gang invite [PlayerID]");
			return 1;
		}
		

		//Create Gang//
		if(gangcmd==1) {
		  if(playerGang[playerid]>0) {
				SendClientMessage(playerid, 0x83BFBFFF, "You are already in a gang!");
				return 1;
		  }

			for(new i = 1; i < MAX_GANGS; i++) {
				if(gangInfo[i][0]==0) {
				  //name gang
					format(gangNames[i], MAX_GANG_NAME, "%s", tmp);
					//Gang exists
					gangInfo[i][0]=1;
					//There is one member
					gangInfo[i][1]=1;
					//Gang color is player's color
					gangInfo[i][2]=playerColors[playerid];

					//Player is the first gang member
					gangMembers[i][0] = playerid;
					format(string, sizeof(string),"You have created the gang '%s' (id: %d)", gangNames[i], i);
					SendClientMessage(playerid, 0x83BFBFFF, string);
					playerGang[playerid]=i;
					//--------SAVEGANG----------------------------------------
					new player[MAX_PLAYERS];
					GetPlayerName(playerid,player,sizeof(player));
					new File:GangFile;
	      	        format(string, sizeof(string), "%s_Gang", player);
		           GangFile = fopen(string, io_append);
		           new var[32];
                   format(var, 32, "Gang:=%s\n",gangNames[i]);fwrite(GangFile, var);
          
		           fclose(GangFile);
					//-------SAVEGANG-------------------------------------------
		      return 1;
				}
			}

			return 1;

		//Join Gang//
		} else if (gangcmd==3) {
	 		gangnum = gangInvite[playerid];

		  if(playerGang[playerid]>0) {
				SendClientMessage(playerid, 0x83BFBFFF, "You are already in a gang.");
				return 1;
		  }
	 		if(gangInvite[playerid]==0) {
				SendClientMessage(playerid, 0x83BFBFFF, "You are not invite in a gang.");
				return 1;
			}
			if(gangInfo[gangnum][0]==0) {
				SendClientMessage(playerid, 0x83BFBFFF, "This gang doesnt exist.");
				return 1;
			}

			if(gangInfo[gangnum][1] < MAX_GANG_MEMBERS) {
			  new i = gangInfo[gangnum][1];

				gangInvite[playerid]=0;

				gangMembers[gangnum][i] = playerid;

			  GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
				for(new j = 0; j < gangInfo[gangnum][1]; j++) {
					format(string, sizeof(string),"%s joined your gang.", sendername);
					SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
				}

				gangInfo[gangnum][1]++;
				playerGang[playerid] = gangnum;

				SetPlayerColor(playerid,gangInfo[gangnum][2]);

				format(string, sizeof(string),"You join the gang '%s'(id: %d)", gangNames[gangnum], gangnum);
				SendClientMessage(playerid, 0x83BFBFFF, string);
				return 1;
			}

			SendClientMessage(playerid, 0x83BFBFFF, "No members searched");
			return 1;

		//Invite to Gang//
		} else if (gangcmd==2) {
	 		giveplayerid = strval(tmp);

			if(playerGang[playerid]==0) {
				SendClientMessage(playerid, 0x83BFBFFF, "You are not in a gang.");
				return 1;
			}
//			if(gangMembers[playerGang[playerid]][0]!=playerid) {
//				SendClientMessage(playerid, COLOR_RED, "You need to be the gang leader to send an invite.");
//				return 1;
//			}

			if(IsPlayerConnected(giveplayerid)) {
				GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
				GetPlayerName(playerid, sendername, sizeof(sendername));

				format(string, sizeof(string),"You invite %s in your gang.", giveplayer);
				SendClientMessage(playerid, 0x83BFBFFF, string);
				format(string, sizeof(string),"You get a gang invite from %s in his gang '%s' (id: %d)", sendername, gangNames[playerGang[playerid]],playerGang[playerid]);
				SendClientMessage(giveplayerid, 0x83BFBFFF, string);

				gangInvite[giveplayerid]=playerGang[playerid];

			} else
				SendClientMessage(playerid, 0x83BFBFFF, "That user doesn't exist!");

		//Leave Gang//
		} else if (gangcmd==4) {
		  PlayerLeaveGang(playerid);
		}

		return 1;
	}

	//------------------- /ganginfo

	if(strcmp(cmd, "/ganginfo", true) == 0) {
	  new gangnum;
		tmp = strtok(cmdtext, idx);

		if(!strlen(tmp) && playerGang[playerid]==0) {
			SendClientMessage(playerid, 0x83BFBFFF, "Type: /ganginfo [GangID]");
			return 1;
		} else if (!strlen(tmp))
			gangnum = playerGang[playerid];
		else
			gangnum = strval(tmp);

		if(gangInfo[gangnum][0]==0) {
			SendClientMessage(playerid, 0x83BFBFFF, "There's no such GANG ID!");
			return 1;
		}

		format(string, sizeof(string),"'%s' Gang members (id: %d)", gangNames[gangnum], gangnum);
		SendClientMessage(playerid, 0x83BFBFFF, string);

		for(new i = 0; i < gangInfo[gangnum][1]; i++) {
			GetPlayerName(gangMembers[gangnum][i], giveplayer, sizeof(giveplayer));
			format(string, sizeof(string),"%s (%d)", giveplayer, gangMembers[gangnum][i]);
			SendClientMessage(playerid, 0x83BFBFFF, string);
		}

		return 1;
	}

	//------------------- /gangs

	if(strcmp(cmd, "/gangs", true) == 0)
	{
		new x;

		SendClientMessage(playerid, 0x83BFBFFF, "Exist gangs:");
	  for(new i=0; i < MAX_GANGS; i++) {
			if(gangInfo[i][0]==1) {
				format(string, sizeof(string), "%s%s(%d) - %d members", string,gangNames[i],i,gangInfo[i][1]);

				x++;
				if(x > 2) {
				  SendClientMessage(playerid, 0x83BFBFFF, string);
				  x = 0;
					format(string, sizeof(string), "");
				} else {
					format(string, sizeof(string), "%s, ", string);
				}
			}
		}

		if(x <= 2 && x > 0) {
			string[strlen(string)-2] = '.';
		  SendClientMessage(playerid, 0x83BFBFFF, string);
		}

		return 1;
		}
These are the lines which saves

Код:
					new player[MAX_PLAYERS];
					GetPlayerName(playerid,player,sizeof(player));
					new File:GangFile;
	            	format(string, sizeof(string), "%s_Gang", player);
		            GangFile = fopen(string, io_append);
		            new var[32];
                    format(var, 32, "Gang:=%s\n",gangNames[i]);fwrite(GangFile, var);
                    fclose(GangFile);
Could someone totally intelligent tell me how to load the gang from the file ?


Bearfist
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)