SA-MP Forums Archive
How do i do this: - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How do i do this: (/showthread.php?tid=245050)



How do i do this: - kickflipdude - 29.03.2011

If i already have something like this under OnPlayerCommand:

public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/Teleport", true) == 0)
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Teleport Menu", "Unity Station \n Los Santos Police Department", "Select", "Cancel");
return 1;
}
return 0;
}


How would I add this onto it:
public OnPlayerCommandText(...)
{
//This will start your engine!
if(strcmp(cmd, "/startengine",true) == 0) {
new vid = GetPlayerVehicleID(playerid);
if(vid != INVALID_VEHICLE_ID) {
GetVehicleParamsEx(vid,engine,lights,alarm,doors,b onnet,boot,objective);
// ||||||
SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,al arm,doors,bonnet,boot,objective);
//VEHICLE_PARAMS_ON is used to start the engine,it purely replace the engine thing!
}
return 1;
}
if(strcmp(cmd, "/stopengine",true) == 0) {
new vid = GetPlayerVehicleID(playerid);
if(vid != INVALID_VEHICLE_ID) {
GetVehicleParamsEx(vid,engine,lights,alarm,doors,b onnet,boot,objective);
// ||||||
SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,a larm,doors,bonnet,boot,objective);
//Here the VEHICLE_PARAMS_OFF will turn off your engine.
}
return 1;
}


Every time i try to add something underneath, it gives me a error. Please help?


Re: How do i do this: - antonio112 - 29.03.2011

pawn Код:
public OnPlayerCommandText(...)
{
if(strcmp(cmd, "/startengine",true) == 0)
{
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
              GetVehicleParamsEx(vid,engine,lights,alarm,doors,b onnet,boot,objective);
              SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,al arm,doors,bonnet,boot,objective);
        }
        return 1;
}
if(strcmp(cmd, "/stopengine",true) == 0)
{
       new vid = GetPlayerVehicleID(playerid);
       if(vid != INVALID_VEHICLE_ID)
       {
                GetVehicleParamsEx(vid,engine,lights,alarm,doors,b onnet,boot,objective);
                SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,a larm,doors,bonnet,boot,objective);
       }
       return 1;
}
if(strcmp(cmdtext, "/Teleport", true) == 0)
{
    ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Teleport Menu", "Unity Station \n Los Santos Police Department", "Select", "Cancel");
    return 1;
}
return 0;
}



Re: How do i do this: - kickflipdude - 29.03.2011

But, how did you do it? i dont understand.


Re: How do i do this: - kickflipdude - 29.03.2011

Stil doesnt work, i get errors


Re: How do i do this: - Serbish - 29.03.2011

I think it's time that you post your errors to see what's wrong.


Re: How do i do this: - kickflipdude - 29.03.2011

C:\Users\Anoop\Desktop\samp03csvr_R2-2_win32\gamemodes\Server.pwn(200) : error 017: undefined symbol "cmd"
C:\Users\Anoop\Desktop\samp03csvr_R2-2_win32\gamemodes\Server.pwn(205) : error 017: undefined symbol "engine"
C:\Users\Anoop\Desktop\samp03csvr_R2-2_win32\gamemodes\Server.pwn(205) : error 017: undefined symbol "onnet"
C:\Users\Anoop\Desktop\samp03csvr_R2-2_win32\gamemodes\Server.pwn(205) : error 029: invalid expression, assumed zero
C:\Users\Anoop\Desktop\samp03csvr_R2-2_win32\gamemodes\Server.pwn(205) : fatal error 107: too many error messages on one line


Re: How do i do this: - SchurmanCQC - 29.03.2011

pawn Код:
public OnPlayerCommandText(...)
{
    if(strcmp(cmd, "/startengine",true) == 0)
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        }
    }
    return 1;
}
    if(strcmp(cmd, "/stopengine",true) == 0)
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
        }
    }
    return 1;
}
    if(strcmp(cmdtext, "/Teleport", true) == 0)
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Teleport Menu", "Unity Station \n Los Santos Police Department", "Select", "Cancel");
        return 1;
    }
    return 0;
}
Had to open this up in pawno, I suck at correcting indentation in the forums.


Re: How do i do this: - kickflipdude - 29.03.2011

1 problem man, the thing is that, my compiler crashes when i try to compile what you wrote.. Help?


Re: How do i do this: - antonio112 - 29.03.2011

pawn Код:
public OnPlayerCommandText(...)
{
    if(strcmp(cmd, "/startengine",true) == 0)
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        }
    }
    return 1;

    if(strcmp(cmd, "/stopengine",true) == 0)
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
        }
    }
    return 1;

    if(strcmp(cmdtext, "/Teleport", true) == 0)
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Teleport Menu", "Unity Station \n Los Santos Police Department", "Select", "Cancel");
        return 1;
    }
    return 0;
}
Try it like this.


Re: How do i do this: - antonio112 - 29.03.2011

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if(strcmp(cmdtext, "/startengine",true) == 0)
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        }
        return 1;
    }


    if(strcmp(cmdtext, "/stopengine",true) == 0)
    {
        new engine,lights,alarm,doors,bonnet,boot,objective;
        new vid = GetPlayerVehicleID(playerid);
        if(vid != INVALID_VEHICLE_ID)
        {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
        }
        return 1;
    }


    if(strcmp(cmdtext, "/Teleport", true) == 0)
    {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Teleport Menu", "Unity Station \n Los Santos Police Department", "Select", "Cancel");
        return 1;
    }
    return 0;
}
Well, you're right Schurman, didn`t really payed attention. Here`s the fixed code. If this doesn`t work, I`ll give up scripting =)

Sorry about my wrong codes earlier ... don`t know what happend.