Get vehicle ID from name?
#5

Try this.

pawn Код:
dcmd_callcar(playerid, params[])
{
    new carname;
    if(sscanf(params, "s", carname))
    {
        SendClientMessage(playerid, COLOR_RED, "[Usage:] /callcar [car name]");
        return 1;
    }
    for(new i; i<MAX_CARS; i++)
    {
        if(!strcmp(params,cInfo[i][Name],true))
        {
            new Float:px, Float:py, Float:pz,
            GetPlayerPos(playerid, px, py, pz);
            SetVehiclePos(i, px-5, py, pz); //i here will only work if the array is organized via vehicle ids
            return 1;
        }
    }
    return 1;
}
I just used i for the vehicle's id. I'm not sure how you organized it. It will work if you did it like cInfo[vehicleid][Name].
Reply


Messages In This Thread
Get vehicle ID from name? - by randomkid88 - 03.06.2010, 05:50
Re: Get vehicle ID from name? - by cessil - 03.06.2010, 06:06
Re: Get vehicle ID from name? - by Backwardsman97 - 03.06.2010, 06:09
Re: Get vehicle ID from name? - by randomkid88 - 03.06.2010, 06:28
Re: Get vehicle ID from name? - by Backwardsman97 - 03.06.2010, 06:38
Re: Get vehicle ID from name? - by randomkid88 - 03.06.2010, 14:48
Re: Get vehicle ID from name? - by RyDeR` - 03.06.2010, 14:52
Re: Get vehicle ID from name? - by randomkid88 - 03.06.2010, 15:34
Re: Get vehicle ID from name? - by Joe_ - 03.06.2010, 15:55
Re: Get vehicle ID from name? - by RyDeR` - 03.06.2010, 19:18

Forum Jump:


Users browsing this thread: 1 Guest(s)