SWITCH problem?
#1

Hello my Dears!

Im realy try to solve this problem since 3-4 weeks. But i cannt alone. I use from Hahn(Fenixzone) the Mechanic Job in my GM. All callbacks works only the repair wont works.

Код:
CMD:get(playerid, params[])
{
	new item[32],Float:X,Float:Y,Float:Z,day,month,year;
	getdate(day,month,year);
	if(IsPlayerConnected(playerid))
	if(sscanf(params, "s[50]", item)) return 1;
	{
	    if(strcmp(item, "rep", true) == 0)
		{
			GetPlayerPos(Mechanic[playerid], X,Y,Z);
			if(Mechanic[playerid] == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED, "[ERROR]:{f5f5dc} No one mechanic has offered repair your vehicle");
			if(!IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_RED, "[ERROR]:{f5f5dc} You must be driving your vehicle to use this command");
			if(Player[playerid][pCash] < MConductor[playerid]) return SendClientMessage(playerid,COLOR_RED, "[ERROR]:{f5f5dc} You do not have enough money");
			if(Player[playerid][jNivel] == 1 && Player[playerid][jExperiencia] < 4) return SendClientMessage(playerid,COLOR_RED, "[ERROR]:{f5f5dc} You need, to have, at least 4 hours of play to accept a repair");
			if(IsPlayerInRangeOfPoint(playerid, 4.0, X,Y,Z))
			{
				new pName[30],string[256],Float:angle,autoid = GetPlayerVehicleID(playerid);
				GetPlayerName(Mechanic[playerid],pName,30);
				GetPlayerFacingAngle(Mechanic[playerid],angle);
				SetPlayerFacingAngle(Mechanic[playerid],angle+180);
				LoopingAnim(Mechanic[playerid],"CAR","Fixn_Car_Loop",4.1,0,0,0,1,15000);<---From here it stops working
				switch(Player[Mechanic[playerid]][pNivelPiloto])
				{
					case 1:
					{
						SetTimerEx("Reparando",15000,false,"d",autoid);
						SetTimerEx("Reparando2",15000,false,"d",Mechanic[playerid]);
						GameTextForPlayer(Mechanic[playerid], "REPAIRING VEHICLE", 15000, 5);
					}
					case 2:
					{

						SetTimerEx("Reparando",13000,false,"d",autoid);
						SetTimerEx("Reparando2",13000,false,"d",Mechanic[playerid]);
						GameTextForPlayer(Mechanic[playerid], "REPAIRING VEHICLE", 13000, 5);
					}
					case 3:
					{

						SetTimerEx("Reparando",9000,false,"d",autoid);
						SetTimerEx("Reparando2",9000,false,"d",Mechanic[playerid]);
						GameTextForPlayer(Mechanic[playerid], "REPAIRING VEHICLE", 9000, 5);
					}
					case 4:
					{

						SetTimerEx("Reparando",6000,false,"d",autoid);
						SetTimerEx("Reparando2",6000,false,"d",Mechanic[playerid]);
						GameTextForPlayer(Mechanic[playerid], "REPAIRING VEHICLE", 6000, 5);
					}
					case 5..100:
					{

						SetTimerEx("Reparando",3000,false,"d",autoid);
						SetTimerEx("Reparando2",3000,false,"d",Mechanic[playerid]);
						GameTextForPlayer(Mechanic[playerid], "REPAIRING VEHICLE", 3000, 5);
					}
				}
				new repuestos = MRepuestos[Mechanic[playerid]];
				LlamadaMeca[playerid] = 0;
				SetPlayerColor(playerid, COLOR_WHITE);
				QuitarDinero(playerid, MConductor[playerid]);
				DarDinero(Mechanic[playerid], MConductor[playerid]);
				Player[Mechanic[playerid]][Repuestos] -= repuestos;
				Mechanic[playerid] = INVALID_PLAYER_ID;
				format(string, sizeof(string), "%s begins to repair the vehicle.",pName);
				ProxDetector(30.0, playerid, string, COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN);
			}
			else return SendClientMessage(playerid,COLOR_RED, "[ERROR]:{f5f5dc} You must be near the mechanic to accept repair");
		}
	}
	return 1;
}
The timers what not working too

Код:
public Reparando2(playerid)
{
	LoopingAnim(playerid, "CARRY", "crry_prtial", 1.0, 0, 0, 0, 0, 0);
	if(Player[playerid][pNivelPiloto] < 49)
	{
		if(Player[playerid][pVIPLevel] == 1)
		{
			new pago = random(3);
			switch(pago)
			{
				case 0:
				{
					Player[playerid][pExpPiloto]++;
					SendClientMessage(playerid,0x0080C2FF,"You have increased your experience with +1 skill point");
				}
				case 1:
				{
					Player[playerid][pExpPiloto]++;
					SendClientMessage(playerid,0x0080C2FF,"You have increased your experience with +1 skill point");
				}
				case 2:
				{
					Player[playerid][pExpPiloto]+= 2;
					SendClientMessage(playerid,0x0080C2FF,"You have increased your experience with +2 skill point");
				}
			}
		}
		else
		{
			Player[playerid][pExpPiloto]++;
			SendClientMessage(playerid,0x0080C2FF,"You have increased your experience with +1 skill point");
		}
	}
	else if(Player[playerid][pNivelPiloto] >= 49)
	{
		Player[playerid][pExpPiloto] = 0;
		Player[playerid][pNivelPiloto]++;
		SendClientMessage(playerid,-1,"Congratulations, you have increased your Mechanic Level");
	}
}

public Reparando(vehicleid)
{
	SetVehicleHealth(vehicleid, 1000.0);
}
when i use /get rep comes: Pretty_Diamond begins to repair the vehicle and the animation turn on but never ends.

Best Regards
And from now ver gratefull for every help!
Reply
#2

No one can help me?
Reply
#3

Hello.

Can you use this Code?
PHP код:
CMD:get(playeridparams[])
{
    new 
item[32],Float:X,Float:Y,Float:Z,day,month,year;
    
getdate(day,month,year);
    if(
IsPlayerConnected(playerid))
    if(
sscanf(params"s[50]"item)) return 1;
    {
        if(
strcmp(item"rep"true) == 0)
        {
            
GetPlayerPos(Mechanic[playerid], X,Y,Z);
            if(
Mechanic[playerid] == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED"[ERROR]:{f5f5dc} No one mechanic has offered repair your vehicle");
            if(!
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,COLOR_RED"[ERROR]:{f5f5dc} You must be driving your vehicle to use this command");
            if(
Player[playerid][pCash] < MConductor[playerid]) return SendClientMessage(playerid,COLOR_RED"[ERROR]:{f5f5dc} You do not have enough money");
            if(
Player[playerid][jNivel] == && Player[playerid][jExperiencia] < 4) return SendClientMessage(playerid,COLOR_RED"[ERROR]:{f5f5dc} You need, to have, at least 4 hours of play to accept a repair");
            if(
IsPlayerInRangeOfPoint(playerid4.0X,Y,Z))
            {
                new 
pName[30],string[256],Float:angle,autoid GetPlayerVehicleID(playerid);
                
GetPlayerName(Mechanic[playerid],pName,30);
                
GetPlayerFacingAngle(Mechanic[playerid],angle);
                
SetPlayerFacingAngle(Mechanic[playerid],angle+180);
                
LoopingAnim(Mechanic[playerid],"CAR","Fixn_Car_Loop",4.1,0,0,0,1,15000);
                
printf("pNivelPiloto: %i",Player[Mechanic[playerid]][pNivelPiloto]);// I added this row
                
switch(Player[Mechanic[playerid]][pNivelPiloto])
                {
                    case 
1:
                    {
                        
SetTimerEx("Reparando",15000,false,"d",autoid);
                        
SetTimerEx("Reparando2",15000,false,"d",Mechanic[playerid]);
                        
GameTextForPlayer(Mechanic[playerid], "REPAIRING VEHICLE"150005);
                    }
                    case 
2:
                    {
                        
SetTimerEx("Reparando",13000,false,"d",autoid);
                        
SetTimerEx("Reparando2",13000,false,"d",Mechanic[playerid]);
                        
GameTextForPlayer(Mechanic[playerid], "REPAIRING VEHICLE"130005);
                    }
                    case 
3:
                    {
                        
SetTimerEx("Reparando",9000,false,"d",autoid);
                        
SetTimerEx("Reparando2",9000,false,"d",Mechanic[playerid]);
                        
GameTextForPlayer(Mechanic[playerid], "REPAIRING VEHICLE"90005);
                    }
                    case 
4:
                    {
                        
SetTimerEx("Reparando",6000,false,"d",autoid);
                        
SetTimerEx("Reparando2",6000,false,"d",Mechanic[playerid]);
                        
GameTextForPlayer(Mechanic[playerid], "REPAIRING VEHICLE"60005);
                    }
                    case 
5..100:
                    {
                        
SetTimerEx("Reparando",3000,false,"d",autoid);
                        
SetTimerEx("Reparando2",3000,false,"d",Mechanic[playerid]);
                        
GameTextForPlayer(Mechanic[playerid], "REPAIRING VEHICLE"30005);
                    }
                }
                new 
repuestos MRepuestos[Mechanic[playerid]];
                
LlamadaMeca[playerid] = 0;
                
SetPlayerColor(playeridCOLOR_WHITE);
                
QuitarDinero(playeridMConductor[playerid]);
                
DarDinero(Mechanic[playerid], MConductor[playerid]);
                
Player[Mechanic[playerid]][Repuestos] -= repuestos;
                
Mechanic[playerid] = INVALID_PLAYER_ID;
                
format(stringsizeof(string), "%s begins to repair the vehicle.",pName);
                
ProxDetector(30.0playeridstringCOLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN,COLOR_LIGHTGREEN);
            }
            else return 
SendClientMessage(playerid,COLOR_RED"[ERROR]:{f5f5dc} You must be near the mechanic to accept repair");
        }
    }
    return 
1;

When you type "/get rep" what Comes in the Server.log?
Reply
#4

@Mencent Hey, you are from Germany like me

The server_log.txt result for this line its : pNivelPiloto: 0

Im supposing this mean i have any issue at my job ranks? wait this is pointed in Reparando and Reparando2 publics.

Variables
Quote:

pNivelPiloto,
pExpPiloto,

Top of Script
Quote:

forward Reparando2(playerid);
forward Reparando(vehicleid);

In My Own Publics Pool at bottom of Script
Quote:

public Reparando2(playerid)
{
LoopingAnim(playerid, "CARRY", "crry_prtial", 1.0, 0, 0, 0, 0, 0);
if(Player[playerid][pNivelPiloto] < 49)
{
if(Player[playerid][pVIPLevel] == 1)
{
new pago = random(3);
switch(pago)
{
case 0:
{
Player[playerid][pExpPiloto]++;
SendClientMessage(playerid,0x0080C2FF,"You have increased your experience with +1 skill point");
}
case 1:
{
Player[playerid][pExpPiloto]++;
SendClientMessage(playerid,0x0080C2FF,"You have increased your experience with +1 skill point");
}
case 2:
{
Player[playerid][pExpPiloto]+= 2;
SendClientMessage(playerid,0x0080C2FF,"You have increased your experience with +2 skill point");
}
}
}
else
{
Player[playerid][pExpPiloto]++;
SendClientMessage(playerid,0x0080C2FF,"You have increased your experience with +1 skill point");
}
}
else if(Player[playerid][pNivelPiloto] >= 49)
{
Player[playerid][pExpPiloto] = 0;
Player[playerid][pNivelPiloto]++;
SendClientMessage(playerid,-1,"Congratulations, you have increased your Mechanic Level");
}
}

public Reparando(vehicleid)
{
SetVehicleHealth(vehicleid, 1000.0);
}
Danke schon mal im voraus das du mir hilfst! Bin echt sehr dankbar!
Reply
#5

I think you made something wrong.
You Need the Code which set the value of pNivelPiloto.

But this (Reparando2) is the Code which is calling when you repair someone isn't it?

(Ich glaube du machst da was falsch. Schick mal bitte den Code, der pNivelPiloto den Wert setzt (sprich dein Skill-Level). Reparando2 ist der Code, der aufgerufen wird, wenn du jemanden reparierst, oder nicht? )
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)