Need some help with Map changing system.
#1

Previously i made a thread and @jamester gave me some codes to change the gamemode from gamemodes folder randomly. but today when i was going to work on it, i saw something that is not suitable for my gamemodes and the thing was timer of changing particular gamemode. It was set to 5 minutes for every gamemode to change.

BUT I WANT to make it different changing timer for each of the gamemodes. is this possible to make from the default codes given by jamester to me?

Here are the codes :

Код:
forward switchmode();
new changemodetimer;

new ModeNames[][] =
{
    {"Racing"},
    {"Fighting"},
    {"anothergame"}
};


public OnGameModeInit()
{
    changemodetimer = SetTimer("switchmode",300000,false);
	return 1;
}

public OnGameModeExit()
{
    KillTimer(changemodetimer);//Kill the timer incase it's still running.
	return 1;
}

public switchmode()
{
    new modestring[50];
    new randmode = random(sizeof(ModeNames)); //Select a random mode name from the array.
    format(modestring,sizeof(modestring),"The Next mode will be %s!",ModeNames[randmode]);
    SendClientMessageToAll(0x32CD32FF,modestring);//Send a message to all online players.
    format(modestring,sizeof(modestring),"changemode %s",ModeNames[randmode]);
    SendRconCommand(modestring);//Change the mode.
    return 1;
}
Reply
#2

eh;

Код:
forward switchmode();

static 
    changemodetimer,
    currentmode
;

enum smode 
{
    Mode[10],
    Time
}

static const ModeInfo[3][smode] =
{
    {"Racing",          300000},
    {"Fighting",        200000},
    {"anothergame",     100000}
};

public OnGameModeInit()
{
    new
        randmode = random( sizeof (ModeNames) );

    currentmode = randmode;
    changemodetimer = SetTimer("switchmode", ModeInfo[currentmode][Time], false);

    return 1;
}

public OnGameModeExit()
{
    KillTimer(changemodetimer);
    currentmode = 0;

	return 1;
}

public switchmode()
{
    new 
        modestring[50],
        randmode = random( sizeof (ModeNames) )
    ;


    format(modestring, sizeof(modestring), "The Next mode will be %s!", ModeInfo[currentmode][Mode]);
    SendClientMessageToAll(0x32CD32FF, modestring);
    format(modestring,sizeof(modestring), "changemode %s", ModeInfo[currentmode][Mode]);
    SendRconCommand(modestring);

    currentmode = randmode;
    changemodetimer = SetTimer("switchmode", ModeInfo[currentmode][Time], false);

    return 1;
}
Reply
#3

Thanks but i got some errors + there are some modes that contains bombing/stealing maps. What if someone steal the vehicle before the timer rans out? ( talking about stealing map )

and here are the errors:

Код:
(50) : warning 228: length of initialler exceeds size of the enum field.
(50) : error 018: initialization data exceeds declared size
Код:
static const ModeInfo[3][smode] =
{
    {"Racing",          300000},
    {"Fighting",        200000},
    {"anothergame",     100000} //line 50
};
Reply
#4

sorry for the bump.
anyone can help me please....?
Reply
#5

I think you can use a player variable to do so, like an administrator can change the map by just a command.

Use something like this [maybe works]:

PHP код:
CMD:cmap1(playerid,params[])
{
 for(new 
iMAX_PLAYERSi++)
{
 
SetPVarInt(i"map1",1);
}
return 
1;

Then on "ongamemodeinit" use " if(getpvarint(playerid, "map1") == 1) " for map1 and do more commands for the other maps and anywhere for functions for map 1 before the code use " if(getpvarint(playerid, "map1") == 1) " , maybe it works?
Reply
#6

{"anothergame", 100000} :/ woried. Use {"Anothergame", 100000}
Reply
#7

Quote:
Originally Posted by karan007
Посмотреть сообщение
I think you can use a player variable to do so, like an administrator can change the map by just a command.

Use something like this [maybe works]:

PHP код:
CMD:cmap1(playerid,params[])
{
 for(new 
iMAX_PLAYERSi++)
{
 
SetPVarInt(i"map1",1);
}
return 
1;

Then on "ongamemodeinit" use " if(getpvarint(playerid, "map1") == 1) " for map1 and do more commands for the other maps and anywhere for functions for map 1 before the code use " if(getpvarint(playerid, "map1") == 1) " , maybe it works?
You mean i should make command to change, if yes then no i want auto change. :'c

Quote:
Originally Posted by SoFahim
Посмотреть сообщение
{"anothergame", 100000} :/ woried. Use {"Anothergame", 100000}
I think you got mad xD joking.
Its not necessary to write the name of mode in capital letters. -__________________-
Reply
#8

Actually:

Код:
forward switchmode();

static 
    changemodetimer,
    currentmode
;

enum smode 
{
    Mode[10],
    Time
}

static const ModeInfo[][smode] =
{
    {"Racing",          300000},
    {"Fighting",        200000},
    {"anothergame",     100000}
};

public OnGameModeInit()
{
    new
        randmode = random( sizeof (ModeInfo) );

    currentmode = randmode;
    changemodetimer = SetTimer("switchmode", ModeInfo[currentmode][Time], false);

    return 1;
}

public OnGameModeExit()
{
    KillTimer(changemodetimer);
    currentmode = 0;

	return 1;
}

public switchmode()
{
    new 
        modestring[50],
        randmode = random( sizeof (ModeInfo) )
    ;


    format(modestring, sizeof(modestring), "The Next mode will be %s!", ModeInfo[currentmode][Mode]);
    SendClientMessageToAll(0x32CD32FF, modestring);
    format(modestring,sizeof(modestring), "changemode %s", ModeInfo[currentmode][Mode]);
    SendRconCommand(modestring);

    currentmode = randmode;
    changemodetimer = SetTimer("switchmode", ModeInfo[currentmode][Time], false);

    return 1;
}
Reply
#9

still same errors.

inb4 I already changed the Modenames to Modeinfo
Reply
#10

I see, "anothergame" exceeds the mode cell size.

Replace Mode[10] with Mode[25]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)