Command not working...
#1

Whats wrong with this command. I changed the command to ZCMD from onPlayercommandText, ect.
Can you fix my code? I will +Rep you.

pawn Code:
new idx;
CMD:v(playerid, params[])
{
    if(pGame[playerid] == 1) return SendClientMessage(playerid, COLOR_RED,"You can not use this command whilst in a mini game!");
    {
   
    new String[200];
    new tmp[256];
    new Float:x, Float:y, Float:z;
    strtok(params, idx);
    tmp = strtok(params, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_RED, "HINT /v [car name]");
   
    new vehicle = GetVehicleModelIDFromName(tmp);
    if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid,COLOR_RED, "That vehicle name you have given was not found, please try again!");

    if(Veh[playerid][VehId] == -1)
    {
        new Float:a;
        GetPlayerFacingAngle(playerid, a);
        GetPlayerPos(playerid, x, y, z);

        if(IsPlayerInAnyVehicle(playerid) == 1)
        {
            GetXYInFrontOfPlayer(playerid, x, y, 8);
        }
        else
        {
            GetXYInFrontOfPlayer(playerid, x, y, 5);
        }

        new PlayersVehicle = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
        Veh[playerid][VehId] = PlayersVehicle;
        LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));
    }
    else
    {
        DestroyVehicle(Veh[playerid][VehId]);
        new Float:a;
        GetPlayerFacingAngle(playerid, a);
        GetPlayerPos(playerid, x, y, z);

        if(IsPlayerInAnyVehicle(playerid) == 1)
        {
            GetXYInFrontOfPlayer(playerid, x, y, 8);
        }
        else
        {
            GetXYInFrontOfPlayer(playerid, x, y, 5);
        }

        new PlayersVehicle = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
        Veh[playerid][VehId] = PlayersVehicle;
        LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));
    }
    format(String, sizeof(String), "You have spawned a %s", aVehicleNames[vehicle - 400]);
    SendClientMessage(playerid,COLOR_ORANGE, String);
    return 1;
    }
}
Reply
#2

i got an easiere way but not like yours
Reply
#3

Can you show how you would have done it please?
Reply
#4

You need the sscanf plugin too

pawn Code:
CMD:v(playerid, params[])
{
    if(pGame[playerid] == 1) return SendClientMessage(playerid, COLOR_RED,"You can not use this command whilst in a mini game!");
   
    new String[200];
    new tmp[32];
 
    if(sscanf(params, "s[32]", tmp)) return SendClientMessage(playerid,COLOR_RED, "HINT /v [car name]");
   
    new vehicle = GetVehicleModelIDFromName(tmp);
    if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid,COLOR_RED, "That vehicle name you have given was not found, please try again!");

    if(Veh[playerid][VehId] != -1)
        DestroyVehicle(Veh[playerid][VehId]);
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerPos(playerid, x, y, z);
    GetPlayerFacingAngle(playerid, a);
    if(IsPlayerInAnyVehicle(playerid))
    {
        GetXYInFrontOfPlayer(playerid, x, y, 8);
    }
    else
    {
        GetXYInFrontOfPlayer(playerid, x, y, 5);
    }
    new PlayersVehicle = CreateVehicle(vehicle, x, y, z, a+90, -1, -1, -1);
    Veh[playerid][VehId] = PlayersVehicle;
    LinkVehicleToInterior(PlayersVehicle, GetPlayerInterior(playerid));
    format(String, sizeof(String), "You have spawned a %s", aVehicleNames[vehicle - 400]);
    SendClientMessage(playerid,COLOR_ORANGE, String);
    return 1;
}
Reply
#5

Ahh thats why, Cheers buddy. +Rep'd you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)