SA-MP Forums Archive
Command doesnt exist but it exist at my gamemode - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Command doesnt exist but it exist at my gamemode (/showthread.php?tid=510690)

Pages: 1 2


Command doesnt exist but it exist at my gamemode - Trynda - 02.05.2014

This
Engine params, doesnt work

pawn Code:
else if(strcmp(params, "engine", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        /*if (vdisabled[GetPlayerVehicleID(playerid)])
        {
        SendClientMessage(playerid, COLOR_RED, "The car's engine is too damaged to start!- Call a mechanic! /service mechanic");
        return 1;
        }*/

        new vehicle = GetPlayerVehicleID(playerid);
        new string[126];
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);

        if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if(Engine[vehicle] == 0)
            {
                if(VehicleBomb[vehicle] == 1)
                {
                    new Float:boomx, Float:boomy, Float:boomz;
                    GetVehiclePos(vehicle, boomx, boomy, boomz);
                    CreateExplosion(boomx, boomy , boomz, 7, 1);
                    if(pMask[playerid] == 1)
                    {
                        format(string, sizeof(string), "* Stranger failed to start the engine and car bomb exploded");
                    }
                    else
                    {
                        format(string, sizeof(string), "* %s failed to start the engine and car bomb exploded", GetPlayerNameEx(playerid));
                    }
                    ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SendClientMessage(playerid, COLOR_YELLOW, "The vehicle exploded because of the car bomb planted by an hitman!");
                    return engine;
                }
                else
                {
                    Engine[vehicle] = 1;
                    SetVehicleParamsEx(vehicle,1,lights,alarm,doors,bonnet,boot,objective);
                    format(string, sizeof(string), "* %s turns the engine of their vehicle engine on.", GetPlayerNameEx(playerid));
                    ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SendClientMessage(playerid, -1, "Vehicle engine started successfully! Type (/car engine) to stop it");
                    return 1;
                }
            }
            else
            {
                Engine[vehicle] = 0;
                SetVehicleParamsEx(vehicle,0,lights,alarm,doors,bonnet,boot,objective);
                format(string, sizeof(string), "* %s turns the vehicles engine off.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                SendClientMessage(playerid, -1, "Vehicle engine stopped. Type (/car engine) to start");
                return 1;
            }
        }
        return engine;
    }
    return 1;
}
how to fix it?


Re: Command doesnt exist but it exist at my gamemode - BroZeus - 02.05.2014

try this
pawn Code:
else if(!strcmp(params, "engine", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
added a "!" before strcmp


Re: Command doesnt exist but it exist at my gamemode - Trynda - 02.05.2014

Quote:
Originally Posted by BroZeus
View Post
try this
pawn Code:
else if(!strcmp(params, "engine", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
added a "!" before strcmp
at the other params it doesnt have "!"

pawn Code:
if(isnull(params))
    {
        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /car [name]");
        SendClientMessage(playerid, COLOR_GREY, "Available names: Engine, Lights, Trunk, Hood");
        return 1;
    }
    else if(strcmp(params, "lights", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510) return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
        SetVehicleLights(vehicleid, playerid);
    }
    else if(strcmp(params, "trunk", true) == 0)
    {
        if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new vehicleid = GetPlayerVehicleID(playerid);
            if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510)
            {
                return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
            }
            SetVehicleTrunk(vehicleid, playerid);
        }
        else if(!IsPlayerInAnyVehicle(playerid))
        {
            new closestcar = GetClosestCar(playerid);
            if(IsPlayerInRangeOfVehicle(playerid, closestcar, 5.0))
            {
                if(GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510)
                {
                    return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
                }
                SetVehicleTrunk(closestcar, playerid);
            }
        }
    }
    else if(strcmp(params, "hood", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new vehicleid = GetPlayerVehicleID(playerid);
            if(GetVehicleModel(vehicleid) == 481 || GetVehicleModel(vehicleid) == 509 || GetVehicleModel(vehicleid) == 510 || IsAPlane(vehicleid) || IsABike(vehicleid))
            {
                return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used in this vehicle.");
            }
            SetVehicleHood(vehicleid, playerid);
        }
        else if(!IsPlayerInAnyVehicle(playerid))
        {
            new closestcar = GetClosestCar(playerid);
            if(IsPlayerInRangeOfVehicle(playerid, closestcar, 5.0))
            {
                if(GetVehicleModel(closestcar) == 481 || GetVehicleModel(closestcar) == 509 || GetVehicleModel(closestcar) == 510 || IsAPlane(closestcar) || IsABike(closestcar))
                {
                    return SendClientMessage(playerid,COLOR_WHITE,"This command can't be used on this vehicle.");
                }
                SetVehicleHood(closestcar, playerid);
            }
        }
    }



Re: Command doesnt exist but it exist at my gamemode - BroZeus - 02.05.2014

where it doesnt have a "!" it works?


Re: Command doesnt exist but it exist at my gamemode - Trynda - 02.05.2014

Quote:
Originally Posted by BroZeus
View Post
where it doesnt have a "!" it works?
Yep,

and i added the "!" before strcmp then it says: warning tag missmatch

Code:
else if(!strcmp(params, "engine", true) == 0 && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)



Re: Command doesnt exist but it exist at my gamemode - BroZeus - 02.05.2014

oh do like this
pawn Code:
else if(!strcmp(params, "engine", true) && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
remove the "== 0" from strcmp then add "!"


Re: Command doesnt exist but it exist at my gamemode - Trynda - 02.05.2014

Quote:
Originally Posted by BroZeus
View Post
oh do like this
pawn Code:
else if(!strcmp(params, "engine", true) && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
remove the "== 0" from strcmp then add "!"
Doesnt work it still saying not exist.

Any advice?


Re: Command doesnt exist but it exist at my gamemode - BroZeus - 02.05.2014

are u using u have nativechecker and sscanf plugins?
if not then use them
and also are other commands in the same FS working?
and on more thing why is this line there "return engine;"
caz if engine is off then it will return a value 0 which will show command doesnt exits


Re: Command doesnt exist but it exist at my gamemode - Trynda - 02.05.2014

Quote:
Originally Posted by BroZeus
View Post
are u using u have nativechecker and sscanf plugins?
if not then use them
and also are other commands in the same FS working?
and on more thing why is this line there "return engine;"
caz if engine is off then it will return a value 0 which will show command doesnt exits
Im using them both
Yes
i dont know
cuz if engine is off it will return the params called "engine" ??, sorry if im wrong at this, im begginner of this things

So how do i fix it? Can you please give the exact code?


Re: Command doesnt exist but it exist at my gamemode - BroZeus - 02.05.2014

remove the line "return engine;"
whats the point of keeping this line just remove this line which i told


Re: Command doesnt exist but it exist at my gamemode - ZombieNest - 02.05.2014

Look for return 0; if it is remove it and add return 1;


Re: Command doesnt exist but it exist at my gamemode - Eth - 02.05.2014

pawn Code:
if(strcmp(params, "engine", true,10) == 0)
    {
        /*if (vdisabled[GetPlayerVehicleID(playerid)])
        {
        SendClientMessage(playerid, COLOR_RED, "The car's engine is too damaged to start!- Call a mechanic! /service mechanic");
        return 1;
        }*/

        new vehicle = GetPlayerVehicleID(playerid);
        new string[126];
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);

        if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if(Engine[vehicle] == 0)
            {
                if(VehicleBomb[vehicle] == 1)
                {
                    new Float:boomx, Float:boomy, Float:boomz;
                    GetVehiclePos(vehicle, boomx, boomy, boomz);
                    CreateExplosion(boomx, boomy , boomz, 7, 1);
                    if(pMask[playerid] == 1)
                    {
                        format(string, sizeof(string), "* Stranger failed to start the engine and car bomb exploded");
                    }
                    else
                    {
                        format(string, sizeof(string), "* %s failed to start the engine and car bomb exploded", GetPlayerNameEx(playerid));
                    }
                    ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SendClientMessage(playerid, COLOR_YELLOW, "The vehicle exploded because of the car bomb planted by an hitman!");
                    return engine;
                }
                else
                {
                    Engine[vehicle] = 1;
                    SetVehicleParamsEx(vehicle,1,lights,alarm,doors,bonnet,boot,objective);
                    format(string, sizeof(string), "* %s turns the engine of their vehicle engine on.", GetPlayerNameEx(playerid));
                    ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SendClientMessage(playerid, -1, "Vehicle engine started successfully! Type (/car engine) to stop it");
                    return 1;
                }
            }
            else
            {
                Engine[vehicle] = 0;
                SetVehicleParamsEx(vehicle,0,lights,alarm,doors,bonnet,boot,objective);
                format(string, sizeof(string), "* %s turns the vehicles engine off.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                SendClientMessage(playerid, -1, "Vehicle engine stopped. Type (/car engine) to start");
                return 1;
            }
        }
        return engine;
    }
    return 1;
}



Re: Command doesnt exist but it exist at my gamemode - Trynda - 02.05.2014

Quote:
Originally Posted by BroZeus
View Post
remove the line "return engine;"
whats the point of keeping this line just remove this line which i told
I removed it,

and i change some of codes, then i figure out the problem is on "if(VehicleBomb[vehicle] == 1)", The vehicle engine is turning on and it says "Command Doesnt Exist"

Some thing like this: when i type /car engine it saying the vehicle engine is on and saying That command doesnt exist at once.

Why?

Code:
[14:22:56] * Kahili turns the engine of their vehicle engine on.

[14:22:56] That {0000FF}command {FFFFFF}does not exist. Use /help to see the commands.
pawn Code:
else if(!strcmp(params, "engine", true) && IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
        /*if (vdisabled[GetPlayerVehicleID(playerid)])
        {
        SendClientMessage(playerid, COLOR_RED, "The car's engine is too damaged to start!- Call a mechanic! /service mechanic");
        return 1;
        }*/

        new vehicle = GetPlayerVehicleID(playerid);
        new string[126];
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);

        if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if(Engine[vehicle] == 0)
            {
                Engine[vehicle] = 1;
                SetVehicleParamsEx(vehicle,1,lights,alarm,doors,bonnet,boot,objective);
                format(string, sizeof(string), "* %s turns the engine of their vehicle engine on.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                // SendClientMessage(playerid, -1, "Vehicle engine started successfully! Type (/car engine) to stop it");
               [B][COLOR="Red"] if(VehicleBomb[vehicle] == 1)
                {
                    new Float:boomx, Float:boomy, Float:boomz;
                    GetVehiclePos(vehicle, boomx, boomy, boomz);
                    CreateExplosion(boomx, boomy , boomz, 7, 1);
                    if(pMask[playerid] == 1)
                    {
                        format(string, sizeof(string), "* Stranger failed to start the engine and car bomb exploded");
                    }
                    else
                    {
                        format(string, sizeof(string), "* %s failed to start the engine and car bomb exploded", GetPlayerNameEx(playerid));
                    }
                    ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SendClientMessage(playerid, COLOR_YELLOW, "The vehicle exploded because of the car bomb planted by an hitman!");[/COLOR][/B]
                }
                else return SendClientMessage(playerid, -1, "Vehicle engine started successfully! Type (/car engine) to stop it");
            }
            else
            {
                Engine[vehicle] = 0;
                SetVehicleParamsEx(vehicle,0,lights,alarm,doors,bonnet,boot,objective);
                format(string, sizeof(string), "* %s turns the vehicles engine off.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                SendClientMessage(playerid, -1, "Vehicle engine stopped. Type (/car engine) to start");
                return 1;
            }
        }
        return SendClientMessage(playerid, COLOR_GRAD1, "This command can only use in vehicle!");



Re: Command doesnt exist but it exist at my gamemode - Trynda - 02.05.2014

wtf?

So i add the CrashDetect, Then it gives me this debug error when i type /car engine

before i add the VehicleBomb[vehicle] == 1

it doenst give this debug error

Code:
02/05/2014 15:31:42] [debug] Run time error 4: "Array index out of bounds"
[02/05/2014 15:31:42] [debug]  Accessing element at index 632 past array upper bound 499
[02/05/2014 15:31:42] [debug] AMX backtrace:
[02/05/2014 15:31:42] [debug] #0 00111788 in public cmd_car (0x00000000, 0x014e0e38) from PHRP_1.2.amx
[02/05/2014 15:31:42] [debug] #1 native CallLocalFunction () [00472ad0] from samp-server.exe
[02/05/2014 15:31:42] [debug] #2 00003dcc in public OnPlayerCommandText (0x00000000, 0x014e0e08) from PHRP_1.2.amx
Now as i said when i type /car engine it says "unknown cmd" but its on my gm

pawn Code:
if(Engine[vehicle] == 0)
        {
            if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                if(VehicleBomb[vehicle] == 1)
                {
                    new Float:boomx, Float:boomy, Float:boomz;
                    GetVehiclePos(vehicle, boomx, boomy, boomz);
                    CreateExplosion(boomx, boomy , boomz, 7, 1);
                    if(pMask[playerid] == 1)
                    {
                        format(string, sizeof(string), "* Stranger failed to start the engine and car bomb exploded");
                    }
                    else
                    {
                        format(string, sizeof(string), "* %s failed to start the engine and car bomb exploded", GetPlayerNameEx(playerid));
                    }
                    ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SendClientMessage(playerid, COLOR_YELLOW, "The vehicle exploded because of the car bomb planted by an hitman!");
                    return 1;
                }
                else
                {
                    Engine[vehicle] = 1;
                    SetVehicleParamsEx(vehicle,1,lights,alarm,doors,bonnet,boot,objective);
                    format(string, sizeof(string), "* %s turns the engine of their vehicle engine on.", GetPlayerNameEx(playerid));
                    ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    SendClientMessage(playerid, -1, "Vehicle engine started successfully! Type (/car engine) to stop it");
                }
            }



Re: Command doesnt exist but it exist at my gamemode - XK - 02.05.2014

Does it show a warning when compiling?


Re: Command doesnt exist but it exist at my gamemode - Trynda - 02.05.2014

Quote:
Originally Posted by XK
View Post
Does it show a warning when compiling?
Nope it doesnt show any warning,

And it only show when i type /car engine


Re: Command doesnt exist but it exist at my gamemode - XK - 02.05.2014

How did you define the VehicleBomb?
The problem might be that you have made it
pawn Code:
new VehicleBomb[MAX_PLAYERS];
But it should be
pawn Code:
new VehicleBomb[MAX_VEHICLES];
Check if you have it defined right way and tell me


Re: Command doesnt exist but it exist at my gamemode - Trynda - 02.05.2014

Quote:
Originally Posted by XK
View Post
How did you define the VehicleBomb?
The problem might be that you have made it
pawn Code:
new VehicleBomb[MAX_PLAYERS];
But it should be
pawn Code:
new VehicleBomb[MAX_VEHICLES];
Check if you have it defined right way and tell me
I dont have the defined,

The VehicleBomb is caming from the /pcb, when you /pcb the VehicleBomb variable will be set to 1

Code:
CMD:pcb(playerid, params[])
{
	if(PlayerInfo[playerid][pFaction] == 4 || PlayerInfo[playerid][pLeader] == 4)
	{
		if(PlayerInfo[playerid][pC4] == 0)
		{
			if(PlayerInfo[playerid][pBombs] != 0)
			{
				new carid = GetPlayerVehicleID(playerid);
				new closestcar = GetClosestCar(playerid, carid);
				if(IsPlayerInRangeOfVehicle(playerid, closestcar, 4.0))
				{
					if(VehicleBomb{closestcar} == 1)
					{
						SendClientMessage(playerid, COLOR_GRAD2, "There is already a C4 on the vehicle engine!");
						return 1;
					}
					VehicleBomb{closestcar} = 1;
					PlacedVehicleBomb[playerid] = closestcar;
					ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0,0,0,0,0);
					ApplyAnimation(playerid,"BOMBER","BOM_Plant",4.0,0,0,0,0,0);
					SendClientMessage(playerid, COLOR_GREEN, "You have placed C4 on the vehicle engine, /pickupbomb to remove it.");
					SendClientMessage(playerid, COLOR_REALRED, "You have placed C4 on the vehicle, Wait till someone start the vehicle engine to explode the bomb");
					PlayerInfo[playerid][pC4] = 1;
					PlayerInfo[playerid][pBombs]--;
					PlayerInfo[playerid][pC4Used] = 2;
I tried to change the closet car to [vehicleid]

Sorry if i have big mistake with this things, im only beginner


Re: Command doesnt exist but it exist at my gamemode - XK - 02.05.2014

well you should have VehicleBomb defined,search for it and paste it,it would be like
pawn Code:
new VehicleBomb //and something after it



Re: Command doesnt exist but it exist at my gamemode - Trynda - 02.05.2014

Quote:
Originally Posted by XK
View Post
well you should have VehicleBomb defined,search for it and paste it,it would be like
pawn Code:
new VehicleBomb //and something after it
Ohh, Ye i have defined

Code:
new VehicleBomb[MAX_VEHICLES char] = 0;