Weird switch problem!
#1

Alright so, I have a big problem, and i can't understand it neither any of my friends, after the person finishes the race that means tries to go through the last race checkpoint, it does nothing at all leaves the checkpoint and reads no code, i did /* */ on the code which after doing it the code went through a bit, but then stops at if(finishcount cause of the disabled switch(..... I have windows 7, on the host it was Linux and it worked perfectly with no misunderstanding.

pawn Код:
if(Joined[playerid] == true)
    {
        if(CPProgess[playerid] == TotalCP -1)
        {
            new
                string[256],
                rFile[256],
                pName2[MAX_PLAYER_NAME],
                Prize[MAX_PLAYERS][2],
                TempTotalTime,
                TempTime[3]
            ;
            new append[3];
            Position++;
            GetPlayerName(playerid, pName2, sizeof(pName2));
            new path[64];
            format(rFile, sizeof(rFile), "/Race/%s.txt", RaceName);
        /*  switch(Position)
            {
                case 1: Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*10)), Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*10)), EndRaceCount = 60, EndRaceTimer = SetTimer("CountTillRaceEnd",999,1), dini_IntSet(path,"RaceFirst",dini_Int(path,"RaceFirst")+1),dUserSetINT(pName(playerid)).("RaceFirst",dUserINT(pName(playerid)).("RaceFirst")+1);
                case 2: Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*9)), Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*9)),dini_IntSet(path,"RaceSecond",dini_Int(path,"RaceSecond")+1),dUserSetINT(pName(playerid)).("RaceSecond",dUserINT(pName(playerid)).("RaceSecond")+1);
                case 3: Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*8)), Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*8)),dini_IntSet(path,"RaceThird",dini_Int(path,"RaceThird")+1),dUserSetINT(pName(playerid)).("RaceThird",dUserINT(pName(playerid)).("RaceThird")+1);
                case 4: Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*7)), Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*7)),dini_IntSet(path,"RaceOther",dini_Int(path,"RaceOther")+1);
                case 5: Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*6)), Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*6)),dini_IntSet(path,"RaceOther",dini_Int(path,"RaceOther")+1);
                case 6: Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*5)), Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*5)),dini_IntSet(path,"RaceOther",dini_Int(path,"RaceOther")+1);
                case 7: Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*4)), Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*4)),dini_IntSet(path,"RaceOther",dini_Int(path,"RaceOther")+1);
                case 8: Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*3)), Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*3)),dini_IntSet(path,"RaceOther",dini_Int(path,"RaceOther")+1);
                case 9: Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*2)), Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*2)),dini_IntSet(path,"RaceOther",dini_Int(path,"RaceOther")+1);
                default: Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*1)), Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*1)),dini_IntSet(path,"RaceOther",dini_Int(path,"RaceOther")+1);
            }
            switch(Position)
            {
                case 1: format(append, sizeof(append), "st");
                case 2: format(append, sizeof(append), "nd");
                case 3: format(append, sizeof(append), "rd");
                default: format(append, sizeof(append), "th");
            }
        */
  format(string, sizeof(string), "*** '%s' finished the %d%s in the '%s' race. Time: %s ***", pName2, Position,append,RaceName,TimeConvert(RaceTime[playerid]));
            SendClientMessageToAll(COLOR_ORANGE, string);
            format(string, sizeof(string), "* You finished the %d%s in the '%s' race. Time: %s *", Position,append,RaceName,TimeConvert(RaceTime[playerid]));
            SendClientMessage(playerid,COLOR_ORANGE, string);
            format(string, sizeof(string), "* You won $%d and %d experience points *", Prize[playerid][0], Prize[playerid][1]);
            SendClientMessage(playerid,COLOR_ORANGE, string);

            if(FinishCount <= 5)
            {
                format(rFile, sizeof(rFile), "/Race/%s.txt", RaceName);
                format(string, sizeof(string), "BestRacerTime_%d", TimeProgress);
                TempTotalTime = dini_Int(rFile, string);
                ConvertTime(var1, TempTotalTime, TempTime[0], TempTime[1], TempTime[2]);
                if(RaceTime[playerid] < dini_Int(rFile, string) || TempTotalTime == 0)
                {
                    dini_IntSet(rFile, string, RaceTime[playerid]);
                    format(string, sizeof(string), "BestRacer_%d", TimeProgress);
                    new append2[3];
                    switch(TimeProgress+1){
                        case 1: format(append2, sizeof(append2), "st");
                        case 2: format(append2, sizeof(append2), "nd");
                        case 3: format(append2, sizeof(append2), "rd");
                        default: format(append2, sizeof(append2), "th");
                    }
                    if(TempTotalTime != 0) format(string, sizeof(string), "*** '%s' broken the '%s' race record of '%s' [%s] in the %d%s place with time: %s ***", pName2,RaceName,dini_Get(rFile, string),TimeConvert(TempTotalTime), TimeProgress+1,append2,TimeConvert(RaceTime[playerid]));
                        else format(string, sizeof(string), "*** '%s' broken a new record in the %d%s place with time: %s ***", pName2, TimeProgress+1,append2,TimeConvert(RaceTime[playerid]));
                    SendClientMessageToAll(COLOR_ORANGE, "  ");
                    SendClientMessageToAll(COLOR_ORANGE, string);
                    format(string, sizeof(string), "BestRacer_%d", TimeProgress);
                    dini_Set(rFile, string, pName2);
                    TimeProgress++;
                }
            }
            GivePlayerMoney(playerid,Prize[playerid][0]);
            dUserSetINT(pName(playerid)).("Experience",dUserINT(pName(playerid)).("Experience")+Prize[playerid][1]);
            if(dUserINT(pName(playerid)).("VIP") == 1)
            {
                dUserSetINT(pName(playerid)).("Experience",dUserINT(pName(playerid)).("Experience")+Prize[playerid][1]/2);
                format(string, sizeof(string),"[VIP PROCENTAI] Gavai papildomai %d patirties nes esi vip.",Prize[playerid][1]/2);
                SendClientMessage(playerid,COLOR_ORANGE,string);
            }
            Joined[playerid] = false;
            DestroyVehicle(CreatedRaceVeh[playerid]);
            DisablePlayerRaceCheckpoint(playerid);
            TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
            CPProgess[playerid] = 0;
            KillTimer(InfoTimer[playerid]);
            RaceTime[playerid]=0;
            TogglePlayerControllable(playerid, true);
            SetCameraBehindPlayer(playerid);
            SetPlayerVirtualWorld(playerid, 0);
            SetPlayerInterior(playerid,PInterior[playerid]);
            KillTimer(ExitRaceTimer[playerid]);
            JoinCount--;
            FlipUsed[playerid] = 0;
            RacePositions[PositionID[playerid]-1] = 0;
            PositionID[playerid] = 0;
            CheckPlayerLevel(playerid);
            SetPlayerPos(playerid,dUserFLOAT(pName(playerid)).("PosX"),dUserFLOAT(pName(playerid)).("PosY"),dUserFLOAT(pName(playerid)).("PosZ"));
            if(JoinCount <= 0)
            {
            format(string, sizeof(string), "** '%s' race ended **",RaceName);
            SendClientMessageToAll(COLOR_ORANGE, string);
            StopRace();
            }
        }
        else
        {
            CPProgess[playerid]++;
            CPCoords[CPProgess[playerid]][0]++;
            RacePosition[playerid] = floatround(CPCoords[CPProgess[playerid]][0], floatround_floor);
            SetCP(playerid, CPProgess[playerid], CPProgess[playerid]+1, TotalCP, RaceType);
            PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);
        }
    }
Reply
#2

I was trying to help him but i couldn't understand what was wrong because i think the code is good...
Reply
#3

So noone knows or ... ?
Reply
#4

Why not just open up the cases instead of trying to shove all the code into one line.

Example.

pawn Код:
case 1:
{
//.
}
Reply
#5

Already tried like that. I tried replacing the code with messages well it worked fine. But i don't know what could be wrong, the files are in their places, there is such variables in them :S
Reply
#6

If you replace it with messages and it works its probably something to do with dini. Maybe wrong destination.
Reply
#7

Well no, the dini isn't modified in any way, and the destination is right.
Reply
#8

pawn Код:
new append[MAX_PLAYERS][3];
            GetPlayerName(playerid, pName2, sizeof(pName2));
            format(rFile, sizeof(rFile), "/Race/%s.txt", RaceName);
            //SetTimerEx("OnPlayerFinishCount",1000,0,"dd",playerid,Position);
            Position++;
            switch(Position)
            {
                case 1:
                {
                    SendClientMessage(playerid,COLOR_ORANGE,"Case viens1");
                    Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*10));
                    Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*10));
                    SendClientMessage(playerid,COLOR_ORANGE,"Case viens2");
                    EndRaceCount = 60;
                    EndRaceTimer = SetTimer("CountTillRaceEnd",999,1);
                    dUserSetINT(pName(playerid)).("RaceFirst",dUserINT(pName(playerid)).("RaceFirst")+1);
                }
                case 2:
                {
                    SendClientMessage(playerid,COLOR_ORANGE,"Case du1");
                    Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*9));
                    Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*9));
                    SendClientMessage(playerid,COLOR_ORANGE,"Case du2");
                    dUserSetINT(pName(playerid)).("RaceSecond",dUserINT(pName(playerid)).("RaceSecond")+1);
                }
                case 3:
                {
                    Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*8));
                    Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*8));
                    dUserSetINT(pName(playerid)).("RaceThird",dUserINT(pName(playerid)).("RaceThird")+1);
                }
                case 4:
                {
                    Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*7));
                    Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*7));
                }
                case 5:
                {
                    Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*6));
                    Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*6));
                }
                case 6:
                {
                    Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*5));
                    Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*5));
                }
                case 7:
                {
                    Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*4));
                    Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*4));
                }
                case 8:
                {
                    Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*3));
                    Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*3));
                }
                case 9:
                {
                    Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*2));
                    Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*2));
                }
                default:
                {
                    Prize[playerid][0] = dini_Int(rFile,"rPrizeMoney")+(random(dini_Int(rFile,"rPrizeMoneyBonus")*1));
                    Prize[playerid][1] = dini_Int(rFile,"rPrizeExp")+(random(dini_Int(rFile,"rPrizeExpBonus")*1));
                }
            }
            switch(Position)
            {
                case 1: format(append[playerid], 3, "st");
                case 2: format(append[playerid], 3, "nd");
                case 3: format(append[playerid], 3, "rd");
                default: format(append[playerid], 3, "th");
            }
I have updated the code and discovered that the PRIZE thing mess this up, i get the message before the prize which is : Case viens1 but after the prize i dont get the msg, i triple-quadruple checked the files they have those variables in them i compared both of 'em a letter to letter
Reply
#9

Help please, I can't figure it out whats wrong, come oon!
Reply
#10

Some help? There's gotta be a way out of this problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)