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



problem in my command - Sarra - 03.08.2014

(I'm a beginner)
Hey I am making a command /car (engine/lights/hood/trunk)
but when I compile the compiler stops working (doesn't even compile and give errors..)
(pawno compiler library has stopped working)
Please just tell me how to fix, don't write the command in your way, give me a solution! I'm a beginner, and I'm still learning,
pawn Код:
CMD:car(playerid, params[])
{
    new string[12];
    new vehicleid=GetPlayerVehicleID(playerid);
    new engine, lights, hood, trunk, a, d, o;
    GetVehicleParamsEx(vehicleid, engine, lights, a, d, hood, trunk, o);
    if (sscanf(params, "s", string)) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /car [engine / lights / hood / trunk]");
    else if (!strcmp(string, "engine"))
        {
            if (engine == 0)
            SetVehicleParamsEx(vehicleid, 1, lights, a, d, hood, trunk, o);
            else
            SetVehicleParamsEx(vehicleid, 0, lights, a, d, hood, trunk, o);
        }
    else if (!strcmp(string, "lights"))
        {
            if (lights == 0)
            SetVehicleParamsEx(vehicleid, engine, 1, a, d, hood, trunk, o);
            else
            SetVehicleParamsEx(vehicleid, engine, 0, a, d, hood, trunk, o);
         }
    else if (!strcmp(string, "hood"))
        {
            if (hood == 0)
            SetVehicleParamsEx(vehicleid, engine, lights, a, d, 1, trunk, o);
            else
            SetVehicleParamsEx(vehicleid, engine, lights, a, d, 1, trunk, o);
         }
    else if (!strcmp(string, "trunk"))
        {
            if (trunk == 0)
            SetVehicleParamsEx(vehicleid, engine, lights, a, d, hood, 1, o);
            else
            SetVehicleParamsEx(vehicleid, engine, lights, a, d, hood, 0, o);
        }
    return 1;
 }
again: please just give me where the problem is, don't give your command


Re: promblem in my command - Sarra - 03.08.2014

any replies?


Re: /car command - Dj_maryo1993 - 03.08.2014

Not soure but try to make it like this :
pawn Код:
if (engine == 0)
{ //add this
   SetVehicleParamsEx(vehicleid, 1, lights, a, d, hood, trunk, o);
} // and close this
else
{ //add this
  SetVehicleParamsEx(vehicleid, 0, lights, a, d, hood, trunk, o);
}//close this



Re: /car command - Stinged - 03.08.2014

I've said this MANY times.
Don't use sscanf for 1 string.

Remove the sscanf line and put this instead.
pawn Код:
if (isnull(params)) // Send the error message
And then change 'string' to 'params' in the strcmp lines.


Re: /car command - Sarra - 03.08.2014

I'm just a beginner , don't blame me -_-
anyway I've tried this
pawn Код:
CMD:say(playerid, params[])
{
    new string;
    if (sscanf(params, "s", string) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /say [Anything you want to say]");
    else SendClientMessage (playerid, 0xFFFFFFFF, "Hello there!");
    return 1;
}
and it works, as you see I used sscanf for one string (Take it easy I might say ridiculous things since I started learning pawno few days ago :P)


Re: /car command - Stinged - 03.08.2014

I don't mean anything, everyone starts from zero. I didn't know anything about scripting when I started.

I'm just saying that it's much better to use params instead of sscanf if you're ONLY USING 1 string.
Can you try what I said before please?


Re: /car command - Sarra - 03.08.2014

Actually, the pawno compiler at the beginning was crashing when I compile(says pawno compiler library stopped working...) But Surprisingly it's now compiling and giving me the errors, It's okay I'll fix the errors
and thanks for the information, I'll try using the "isnull" thanks +rep


Re: /car command - Sarra - 03.08.2014

What's meant by "Tag Mismatch"? last warning left; I updated the post, it's now okay, but it has just the tag mismatch warning, can you tell me what it is so I can fix it?


Re: /car command - Sarra - 03.08.2014

Fixed it thanks
maybe I should rep+ myself :P