Multiple questions.
#1

So, I'm trying to make a round system for my gamemode, which has turned out to be working more or less. Sadly, the money doesn't work tho. When the murderer or police get money, and afterwards die, their money re-sets to 0.

pawn Код:
#include <a_samp>

main()
{
}

// TEAMS
#define SWAT 0
#define MURDERER 1

// New defines
new gTeam[MAX_PLAYERS]; // New "table", holding all the players
new countTimer; // counter Time
new count; // Storing every counting
new newCount[128]; // New count after format
new newMoney[128]; // New cash after format
new Text:MurdererText; // The murderer text
new IsRound = 0; // If a round is on, then the var is 1

// Forwards
forward SurvivedTime(playerid); // Updating the function   

//COLORS
#define COLOR_GREEN 0x33AA33AA
#define COLOR_YELLOW 0xeaae0aFF
#define COLOR_BLUE 0x3A47DEFF
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BLACK 0x00000000

public SurvivedTime(playerid)
{
    count = count + 1;
   
    format(newCount,sizeof(newCount), "The murderer has stayed alive for %d seconds!",count);
       
    TextDrawShowForAll(MurdererText); // Show the textdraw to a certain player
    TextDrawSetString(MurdererText, newCount);  
    return 1;
}

public OnGameModeInit()
{
//Misc
SetGameModeText("Daniel");
ShowPlayerMarkers(1);
ShowNameTags(1);

MurdererText = TextDrawCreate(188 ,415 , "");
TextDrawFont(MurdererText , 2);
TextDrawLetterSize(MurdererText , 0.3, 2.8000000000000003);
TextDrawColor(MurdererText , COLOR_YELLOW);
TextDrawSetOutline(MurdererText , false);
TextDrawSetProportional(MurdererText , true);
TextDrawSetShadow(MurdererText , 1);
   
//Classes
AddPlayerClassEx(SWAT,286,-1348.1112,492.7941,18.2344,359.6147,29,100,24,30,0,0); // FBI Spawn 1
AddPlayerClassEx(SWAT,165,-1348.1112,492.7941,18.2344,359.6147,29,100,24,30,0,0); // FBI Spawn 2
AddPlayerClassEx(SWAT,166,-1348.1112,492.7941,18.2344,359.6147,29,100,24,30,0,0); // FBI Spawn 3
AddPlayerClassEx(SWAT,285,-1348.1112,492.7941,18.2344,359.6147,29,100,24,30,0,0); // FBI Spawn 4
AddPlayerClassEx(MURDERER,127,2842.8140,1336.4701,11.3906,3.6087,30,200,25,80,23,50); // Killer

// Police Cars
AddStaticVehicle(593,-1456.0219,509.0618,18.7183,268.9087,60,1); // Police Plane 1
AddStaticVehicle(593,-1456.2622,494.2163,18.7439,269.8539,22,1); // Police Plane 2
AddStaticVehicle(497,-1416.9177,517.3682,18.4195,271.3942,0,1); // Police Helicopter 1
AddStaticVehicle(430,-1440.3995,507.5984,-0.3618,91.5993,46,26); // Police Boat 1
AddStaticVehicle(430,-1447.8242,494.9949,-0.0959,91.7357,46,26); // Police Boat 2
AddStaticVehicle(490,-1427.0908,455.9612,7.3116,0.8476,0,0); // FBI Car 1
AddStaticVehicle(490,-1431.0042,456.0098,7.3194,2.4484,0,0); // FBI Car 2
AddStaticVehicle(490,-1435.1392,456.1134,7.3166,1.2914,0,0); // FBI Car 3
AddStaticVehicle(523,-1412.7231,454.8123,6.7520,357.6720,0,0); // Police Bike 1
AddStaticVehicle(523,-1414.9354,454.7876,6.7533,356.1974,0,0); // Police Bike 2
AddStaticVehicle(523,-1416.9554,455.0000,6.7398,358.0082,0,0); // Police Bike 3
AddStaticVehicle(601,-1405.7280,457.1820,6.9396,1.3267,1,1); // SWAT Van 1
AddStaticVehicle(528,-1391.5667,456.2906,7.2317,0.0865,0,0); // FBI Mini Van 1
AddStaticVehicle(528,-1396.1521,456.3970,7.2328,0.1226,0,0); // FBI Mini Van 2

// Police Base
CreateObject(969, -1534.681763, 482.154999, 6.354377, 0.0000, 0.0000, 268.8998);
CreateObject(969, -1534.719849, 473.235901, 6.354377, 0.0000, 0.0000, 272.3375);
CreateObject(969, -1534.326416, 464.323273, 6.354377, 0.0000, 0.0000, 342.8113);
CreateObject(969, -1525.898315, 461.710358, 6.354377, 0.0000, 0.0000, 339.3735);
CreateObject(3279, -1529.526978, 468.432068, 6.263117, 0.0000, 0.0000, 0.0000);
CreateObject(1238, -1552.621216, 508.421967, 6.349430, 0.0000, 0.0000, 0.0000);
CreateObject(1238, -1551.082153, 520.835083, 6.349430, 0.0000, 0.0000, 0.0000);
CreateObject(982, -1518.821411, 504.583344, 6.863242, 0.0000, 0.0000, 0.0000);
CreateObject(982, -1531.556274, 518.747681, 6.863242, 0.0000, 0.0000, 263.7431);
CreateObject(982, -1548.137817, 494.820587, 6.863242, 0.0000, 0.0000, 7.7349);
CreateObject(5822, -1406.370239, 482.976044, 11.886078, 0.0000, 0.0000, 95.3974);
CreateObject(984, -1332.927246, 458.693207, 6.824180, 0.0000, 0.0000, 0.0000);
CreateObject(984, -1332.946411, 471.519073, 6.824180, 0.0000, 0.0000, 0.0000);
CreateObject(983, -1335.494141, 452.063690, 6.871055, 0.0000, 0.0000, 275.7751);
CreateObject(983, -1332.988403, 478.797058, 6.864470, 0.0000, 0.0000, 0.0000);
CreateObject(983, -1546.856323, 520.288208, 6.863242, 0.0000, 0.0000, 265.4620);

// Mafia Cars
AddStaticVehicle(410,2839.6235,1374.6736,10.4207,358.7050,10,1); // Mafia Car 1
AddStaticVehicle(410,2842.7437,1374.7450,10.4336,0.1218,9,1); // Mafia Car 2
AddStaticVehicle(419,2845.6255,1375.1077,10.5907,1.1053,47,76); // Mafia Car 3
AddStaticVehicle(419,2849.0698,1375.1388,10.6067,358.7775,33,75); // Mafia Car 4
AddStaticVehicle(463,2853.4409,1367.8137,10.3519,268.7517,84,84); // Mafia Car 5
AddStaticVehicle(463,2853.3572,1364.3982,10.3525,273.2110,7,7); // Mafia Car 6
AddStaticVehicle(555,2853.4519,1361.3632,10.4952,270.1581,58,1); // Mafia Car 7
AddStaticVehicle(555,2853.4690,1358.1014,10.4963,270.0750,58,1); // Mafia Car 8
AddStaticVehicle(568,2853.2932,1354.9575,10.6777,271.5279,9,39); // Mafia Car 9
AddStaticVehicle(568,2853.2190,1351.7885,10.6821,269.6222,9,39); // Mafia Car 10

return 1;
}

SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0)
    {
        gTeam[playerid] = SWAT;
    }

    else if(classid == 4)
    {
        gTeam[playerid] = MURDERER;
    }

return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid,220.3261,1822.9734,7.5368);//The Place postion
SetPlayerCameraLookAt(playerid,220.3261,1822.9734,7.5368);//Camera Look at the player
SetPlayerCameraPos(playerid,226.7491,1823.0441,7.4141);//Camera Postiion
SetPlayerFacingAngle(playerid, 270 );//The Facing Angle
   
SetPlayerTeamFromClass(playerid, classid);//It set's the player to the choosing team

switch(GetPlayerSkin(playerid))
    {
    case 286, 165, 166, 285: GameTextForPlayer(playerid, "~b~Police Forces", 1000, 4);
    case 127: GameTextForPlayer(playerid, "~r~Murderer", 1000, 4);
    }
return 1;
}

StartRound(playerid)
{
    countTimer = SetTimerEx("SurvivedTime", 1000, true, "i", playerid); // start the timer
    IsRound = 1; // Show that the round is ongoing
    count = 0; // Reset count
}

EndRound(playerid)
{
    format(newMoney,sizeof(newMoney), "You survived for %d seconds, and for that you get $%d.",count, count);
    KillTimer(countTimer); // Kill the count timer
    IsRound = 0; // End the round variable.
    TextDrawShowForAll(MurdererText); // Show the textdraw to a certain player
    TextDrawSetString(MurdererText, "Round ended!");
    if (gTeam[playerid] == MURDERER){
    GivePlayerMoney(playerid, GetPlayerMoney(playerid) + count);
    SendClientMessage(playerid, COLOR_YELLOW, newMoney);
    }
}

public OnPlayerSpawn(playerid)
{
if (gTeam[playerid] == SWAT)
    {
    SetPlayerArmour(playerid, 100);
    SetPlayerColor(playerid, COLOR_BLUE);
    }
    else if (gTeam[playerid] == MURDERER)
    {
    SetPlayerColor(playerid, COLOR_BLACK);
    }
   
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if (IsRound == 1){
    if (gTeam[killerid] == SWAT){
    GivePlayerMoney(killerid,  GetPlayerMoney(killerid) + 1000);
    SendClientMessage(killerid, COLOR_BLUE, "You killed the murderer and the police won! You earned $1000");
    }
    if (gTeam[killerid] == MURDERER){
    GivePlayerMoney(killerid,  GetPlayerMoney(killerid) + 500);
    SendClientMessage(killerid, COLOR_BLUE, "You killed a government official! You earned $200");
    }
    if (gTeam[playerid] == MURDERER)
    {
    EndRound(playerid);
    }
    }
    return 1;
    }

public OnPlayerCommandText(playerid, cmdtext[])
{
 if(strcmp(cmdtext, "/roundstart", true) == 0){
StartRound(playerid);
return 1;
}
 if (strcmp(cmdtext, "/roundend", true) == 0){
EndRound(playerid);
return 1;
}

 return 0;
 
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)