`Cop Chase` minigame.
#1

Hello!

I`m trying to make "Cop Chase" minigame.
As you can see 1 suspect and 9cops[Max]
When "TTA == 0" its spawn only suspect in "SSCAR" and thats all.
I realy dont know where is problem, i`ve tried fix this almoust 1h.






Код:
/* ---------------------------------------------------------------------------*/
#include <a_samp>
#include <zcmd>
#include <foreach>
#define SCM SendClientMessage
#define     CCD                   1/*-----------Copchase InfoDialog           */
#define     RED                   0xC60000FF/*-----------Cpolor Red           */
#define   S_MAX                   1/*-----------Max suspect                   */
#define   P_MAX                   9/*-----------Max Police                    */
#define     CC_MAX                10/*-----------CopChase Max players         */
#define     CC_MIN                3/* -----------Copchase Min players         */
#define     CC_VW                 3
/* ---------------------------------------------------------------------------*/
new
     PICC,
     PlayerINCC[MAX_PLAYERS],
     TTA,
	 Text:TTT,
     SSCAR,
	 PoliceCar,
     TEAMP[MAX_PLAYERS],
     TEAMS[MAX_PLAYERS],
     SUSPECT,
     POLICE,
     bool:IsRaceRunning = false;

forward balance();
forward CopChase();
/* ---------------------------------------------------------------------------*/

enum e_spawns
{
	Float:spawnPos[3],
	spawnUsed
}
new spawns[][e_spawns] =
{
         {{2618.4744, -2204.1370, 13.3695},0},
         {{2613.1169, -2203.7178, 13.3695},0},
         {{2607.8311, -2203.6399, 13.3695},0},
         {{2602.7195, -2203.6812, 13.3695},0},
         {{2597.3818, -2203.6343, 13.3695},0},
         {{2597.3276, -2193.8452, 13.3695},0},
         {{2602.8567, -2194.4163, 13.3695},0},
         {{2608.0422, -2194.2698, 13.3695},0},
         {{2613.3118, -2194.6567, 13.3695},0},
         {{2618.9937, -2194.9639, 13.3695},0}
};
forward spawnAvailable(spawn);
public spawnAvailable(spawn)
{
    spawns[spawn][spawnUsed] = 0;
}
/* ---------------------------------------------------------------------------*/
main()
{
	print("\n----------------------------------");
	print(" COP CHASE V1.0 ");
	print("----------------------------------\n");
}
public OnGameModeInit()
{
	SetGameModeText("* COP CHASE *");
	SSCAR = CreateVehicle(542, 2606.4771, -2228.3059, 13.1140, 88.6200, -1, -1, 100);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
	TEAMS[i] = 0;
    TEAMP[i] = 0;
    SUSPECT--;
    POLICE--;
    }
	IsRaceRunning = false;
	return 1;
}

CMD:cc(playerid, params[])
{
    ShowPlayerDialog(playerid, CCD, DIALOG_STYLE_MSGBOX, "      {B35900}COPCHASE INFORMACIJA", "{C60000}Noziedzniekam:{FFFFFF}\n{FFFFFF}-Aizmukt no policistiem 10 minutes\n{FFFFFF}-Nenomirt\n{000080}-Policistiem:\n{FFFFFF}Nokert noziedznieku 10 minutes.\n{FFFFFF}Lieto Y lai butu redzams karte.\n{FFFFFF}Lieto `![teksts]` lai sazinatos ar policistiem.", "{7E7E7E}Sapratu", "");
    if(PICC >= CC_MAX) return SendClientMessage(playerid, 0xFFFFFFFF, "[COPCHASE]: COPCHASE ir pilns! {CC0000}10{FFFFFF}/10");
    if(PlayerINCC[playerid] == 1)return SendClientMessage(playerid, RED, "Tu jau esi pievienojies!");
    if(IsRaceRunning == true)return SendClientMessage(playerid, RED, "COPCHASE jau sacies!");
    else if(PlayerINCC[playerid] == 0 && IsRaceRunning == false)
    {
           PICC++;
           new string[64];
           format(string,sizeof(string),"[COPCHASE]: Dalibnieki: {008200}%d{FFFFFF}/10",PICC);
           SendClientMessageToAll(0xFFFFFFFF, string);
           SendClientMessageToAll(0xFFFFFFFF, "{008200}/cc{FFFFFF} lai pievienotos!");
           SendClientMessage(playerid, 0xFFFFFFFF, "{008200}/exitcc{FFFFFF} lai izietu!");
           PlayerINCC[playerid] = 1;
           TTA = 30;
           SetTimer("CopChase", 1000, 1);
	}
    return 1;
}


CMD:exitcc(playerid, params[])
{
    PICC--;
    SUSPECT--;
    POLICE--;
    new name[MAX_PLAYER_NAME], string[100];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s {CC0000}IZGAJA{FFFFFF} no copchase!", name);
    SendClientMessageToAll(0xFFFFFFFF, string);
    new string3[64];
    format(string3,sizeof(string3),"[COPCHASE]: Dalibnieki: {CC0000}%d{FFFFFF}/10",PICC);
    SendClientMessageToAll(0xFFFFFFFF, string3);
    PlayerINCC[playerid] = 0;
    return 1;
}


public CopChase()
{
	TTA--;
    if(TTA > 0)
    {
	    new string8[128];
	    format(string8, 128, "Starts: %d!", TTA);//[----- Teksta formвts -----]
	    TextDrawSetString(Text:TTT, string8);
	    TextDrawShowForAll(Text:TTT);
    }
    if(TTA == 10)
    {
     SendClientMessageToAll(0xFFFFFFFF, "{008200}*{FFFFFF}COPCHASE{008200}*{FFFFFF} saksies pзc 20 sekundem! Pievienojies {008200}/copchase{FFFFFF}!");
    }
    if(TTA == 0)
    {
       KillTimer(TTA);
       TextDrawDestroy(TTT);
       IsRaceRunning = true;
       new rand = random(sizeof(spawns));
       while(spawns[rand][spawnUsed])
       rand = random(sizeof(spawns));
       spawns[rand][spawnUsed] = 1;
       PoliceCar = CreateVehicle(596,spawns[rand][spawnPos][0],spawns[rand][spawnPos][1],spawns[rand][spawnPos][2],180.0000,-1,-1,0);
       for(new CCPL = 0; CCPL < MAX_PLAYERS; CCPL++)
         {
                     SetPlayerVirtualWorld(CCPL, CC_VW);
                     SetVehicleVirtualWorld(PoliceCar, CC_VW);
                     SetVehicleVirtualWorld(SSCAR, CC_VW);
                     new RP = Iter_Random(Player);
                     TEAMS[RP] = 1, TEAMP[CCPL] = 1;
                     SUSPECT++, POLICE++;
                     if(TEAMS[RP] == 1 && SUSPECT++)return  SetPlayerSkin(CCPL, 122), PutPlayerInVehicle(CCPL, SSCAR, 0);
                     if(TEAMP[CCPL] == 1 && POLICE++)return SetPlayerSkin(CCPL, 265), PutPlayerInVehicle(CCPL,PoliceCar,0);
		 }
	}
    return 1;
}
public balance()
{
	if (SUSPECT > S_MAX)
	{
	  	POLICE++;
	}
	return 1;
}
Reply
#2

Do you make it a habit to create the most non-informative variable names ever? I don't know what PICC or TTA or SSCAR is, and I guarantee that when you come back to this script in a few months you won't either.
Reply
#3

Код:
I don't know what PICC or TTA or SSCAR
PICC = Players in copchase.
Код:
if(PICC >= CC_MAX) return SendClientMessage(playerid, 0xFFFFFFFF, "Minigame is full {CC0000}10{FFFFFF}/10");
TTA = timer.
Код:
TTA = 30;
SSCAR = suspect car.
Код:
SSCAR = CreateVehicle(542, 2606.4771, -2228.3059, 13.1140, 88.6200, -1, -1, 100);
Reply
#4

Vince, I guess everyone has his own style of scripting which includes their thoughts of creating variable names, although I don't deny that the given variable names are pretty funny though.
Reply
#5

lol, thank you guys for help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)