SA-MP Forums Archive
/car command not working - 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: /car command not working (/showthread.php?tid=353514)



/car command not working - Swyft™ - 23.06.2012

Well I am trying to transfer a /car command from SeifAdmin to my script, because I need it for something on the script to work.... here is the command

pawn Код:
CMD:car(playerid, params[])
{
    if(DMZone[playerid] == 0)
    {
        new string[256];
        new car = GetVehicleModelIDFromName(tmp);
        if(isnull(params))
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /car [vehicleid|name] [color1] [color2]"), true;
        new color1 = strval(tmp);
        new color2 = strval(tmp);

        new Float:X,Float:Y,Float:Z,Float:A;
        GetPlayerPos(playerid, X,Y,Z);
        GetPlayerFacingAngle(playerid, A);
        X += (5 * floatsin(-A, degrees));
        Y += (5 * floatcos(-A, degrees));
        new carid = CreateVehicle(car, X,Y,Z, 0.0, color1, color2, 600000000);
        format(string, sizeof(string), "Vehicle %s(%d) spawned.", VehNames[GetVehicleModel(carid)-400], carid);
        SendClientMessage(playerid, COLOR_YELLOW, string);
    }
    if(DMZone[playerid] == 1) return SendClientMessage(playerid, COLOR_RED,"ERROR: You are in a DM Zone");
    return 1;
}
Remember this is transfered from Seif Admin to here. I get these 3 errors

Код:
\gamemodes\FD.pwn(3100) : error 017: undefined symbol "tmp"
\gamemodes\FD.pwn(3103) : error 017: undefined symbol "tmp"
\gamemodes\FD.pwn(3104) : error 017: undefined symbol "tmp"
Can someone please help me


Respuesta: /car command not working - Chris1337 - 23.06.2012

pawn Код:
CMD:car(playerid, params[])
{
    if(DMZone[playerid] == 0)
    {
        new string[256];
        new car = GetVehicleModelIDFromName(vehname[]);
        new color1;
        new color2;
        if(!sscanf(params, "iii",car,  color1, color2); return SendClientMessage(playerid, COLOR_GREY, "USAGE: /car [vehicleid|name] [color1] [color2]"), true;

        new Float:X,Float:Y,Float:Z,Float:A;
        GetPlayerPos(playerid, X,Y,Z);
        GetPlayerFacingAngle(playerid, A);
        X += (5 * floatsin(-A, degrees));
        Y += (5 * floatcos(-A, degrees));
        new carid = CreateVehicle(car, X,Y,Z, 0.0, color1, color2, 600000000);
        format(string, sizeof(string), "Vehicle %s(%d) spawned.", VehNames[GetVehicleModel(carid)-400], carid);
        SendClientMessage(playerid, COLOR_YELLOW, string);
    }
    if(DMZone[playerid] == 1) return SendClientMessage(playerid, COLOR_RED,"ERROR: You are in a DM Zone");
    return 1;
}
try this


Re: /car command not working - Swyft™ - 23.06.2012

Undefined symbol vehname[]


Re: /car command not working - igal4576 - 23.06.2012

try to find: "public OnPlayerCommandText" on your mod, and put: "new tmp[128];" under it

like:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new tmp[128];
and replace the script with that:

pawn Код:
CMD:car(playerid, params[])
{
    if(DMZone[playerid] == 0)
    {
        new string[256];
        tmp = strtok(cmdtext, idx);
        new car = GetVehicleModelIDFromName(tmp);
        if(isnull(params))
        return SendClientMessage(playerid, COLOR_GREY, "USAGE: /car [vehicleid|name] [color1] [color2]"), true;
        new color1 = strval(tmp);
        new color2 = strval(tmp);

        new Float:X,Float:Y,Float:Z,Float:A;
        GetPlayerPos(playerid, X,Y,Z);
        GetPlayerFacingAngle(playerid, A);
        X += (5 * floatsin(-A, degrees));
        Y += (5 * floatcos(-A, degrees));
        new carid = CreateVehicle(car, X,Y,Z, 0.0, color1, color2, 600000000);
        format(string, sizeof(string), "Vehicle %s(%d) spawned.", VehNames[GetVehicleModel(carid)-400], carid);
        SendClientMessage(playerid, COLOR_YELLOW, string);
    }
    if(DMZone[playerid] == 1) return SendClientMessage(playerid, COLOR_RED,"ERROR: You are in a DM Zone");
    return 1;
}
rep if you find it useful


Respuesta: /car command not working - Chris1337 - 23.06.2012

whats your stock of this :

pawn Код:
GetVehicleModelIDFromName



Re: /car command not working - Swyft™ - 23.06.2012

pawn Код:
stock GetVehicleModelIDFromName(vehname[])
{
    for(new i = 0; i < 211; i++)
    {
        if (strfind(VehNames[i], vehname, true) != -1) return i + 400;
    }
    return -1;
}



Respuesta: /car command not working - Chris1337 - 23.06.2012

pawn Код:
CMD:car(playerid, params[])
{
    if(DMZone[playerid] == 0)
    {
        new string[256];
        new color1;
        new color2;
        new car;
        if(!sscanf(params, "iii",car,  color1, color2); return SendClientMessage(playerid, COLOR_GREY, "USAGE: /car [vehicleid|name] [color1] [color2]"), true;

        new Float:X,Float:Y,Float:Z,Float:A;
        GetPlayerPos(playerid, X,Y,Z);
        GetPlayerFacingAngle(playerid, A);
        X += (5 * floatsin(-A, degrees));
        Y += (5 * floatcos(-A, degrees));
        new car1 = GetVehicleModelIDFromName(car)
        CreateVehicle(car1, X,Y,Z, 0.0, color1, color2, 600000000);
        format(string, sizeof(string), "Vehicle %s(%d) spawned.", VehNames[GetVehicleModel(carid)-400], carid);
        SendClientMessage(playerid, COLOR_YELLOW, string);
    }
    if(DMZone[playerid] == 1) return SendClientMessage(playerid, COLOR_RED,"ERROR: You are in a DM Zone");
    return 1;
}
try this


Re: /car command not working - Swyft™ - 23.06.2012

C:\Users\EASYHOME\Desktop\FuriousDrifters\gamemode s\FD.pwn(3111) : error 035: argument type mismatch (argument 1)
C:\Users\EASYHOME\Desktop\FuriousDrifters\gamemode s\FD.pwn(3113) : error 017: undefined symbol "carid"
C:\Users\EASYHOME\Desktop\FuriousDrifters\gamemode s\FD.pwn(3103) : warning 203: symbol is never used: "car"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Errors.


Respuesta: /car command not working - Chris1337 - 23.06.2012

pawn Код:
COMMAND:car(playerid, params[])
{
    if(DMZone[playerid] == 0)
    {
        new vehiclename, carcolour1, carcolour2;
        if(sscanf(params, "iii", vehiclename, carcolour1, carcolour2)) return SendClientMessage(playerid, 0xFF00FFFF, "[Incorrect Usage!] [Correct Usage]- /car (vehicle name) (colour1) colour2)");
        {
            new Float:X, Float:Y, Float:Z;
            GetPlayerPos(playerid, X, Y, Z);
            GetPlayerFacingAngle(playerid, A);
            X += (5 * floatsin(-A, degrees));
             Y += (5 * floatcos(-A, degrees));
            new model = GetVehicleModelIDFromName(vehiclename)
            AddStaticVehicleEx(model,X+2, Y+2, Z+5, 0, carcolour1, carcolour2, -1);
            PutPlayerInVehicle(playerid,model, 0);
            SetVehicleHealth(model, 998);
         }
     }
if(DMZone[playerid] == 1) return SendClientMessage(playerid, COLOR_RED,"ERROR: You are in a DM Zone");
    return 1;
}



Re: /car command not working - Swyft™ - 23.06.2012

C:\Users\EASYHOME\Desktop\FuriousDrifters\gamemode s\FD.pwn(310 : error 035: argument type mismatch (argument 1)