SA-MP Forums Archive
Whats wrong with 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: Whats wrong with this? (/showthread.php?tid=126086)



Whats wrong with this? - Torran - 07.02.2010

pawn Код:
dcmd_open(playerid, params[])
{
    if(strcmp(params,"lvpd",true) == 0) return SendClientMessage(playerid,0xFF0000FF,"Usage: /open [gate]");
    {
    if(IsPlayerInAnyVehicle(playerid))
    {
    if(IsPlayerInRangeOfPoint(playerid, 10.0, 2294.230713, 2499.273682, 5.752781))
    {
    MoveObject(lvgate1,2294.230713, 2507.217041, 5.752781,2);
    SetTimer("LVGates1",9000,0);
    }
    else
    {
    if(IsPlayerInRangeOfPoint(playerid, 10.0, 2334.719971, 2443.472900, 8.230819))
    {
    MoveObject(lvgate2,2330.758057, 2436.558838, 8.230819,2);
    SetTimer("LVGates2",9000,0);
    }
}
    }
}
    return 1;
}
Im new to using params like that, So anyway,
If i type /open, It sends usage, If i type /open lvpd, It sends usage,
But if i type /open isjdfioujs or anything /open sodfjso just anything after /open, It will open,
Why?


Re: Whats wrong with this? - Miguel - 07.02.2010

pawn Код:
dcmd_open(playerid, params[])
{
    #pragma unused params
    if(strcmp(params,"lvpd",true) == 0) // return SendClientMessage(playerid,0xFF0000FF,"Usage: /open [gate]"); THIS!!!!!!!!!!!!!!!!!!!!
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(IsPlayerInRangeOfPoint(playerid, 10.0, 2294.230713, 2499.273682, 5.752781))
            {
                MoveObject(lvgate1,2294.230713, 2507.217041, 5.752781,2);
                SetTimer("LVGates1",9000,0);
            }
            else
            {
                if(IsPlayerInRangeOfPoint(playerid, 10.0, 2334.719971, 2443.472900, 8.230819))
                {
                    MoveObject(lvgate2,2330.758057, 2436.558838, 8.230819,2);
                    SetTimer("LVGates2",9000,0);
                }
            }
        }
    }
    return 1;
}



Re: Whats wrong with this? - Torran - 07.02.2010

What? I got it off something else that does like a /level 1 2 3 4 5 thing,
But whats wrong with it


Re: Whats wrong with this? - mansonh - 07.02.2010

Yah the issue with your code was that you were doing an
if() asdasd;
{

you can end an if statement with ; and use a { at the same time.


Re: Whats wrong with this? - Torran - 07.02.2010

Quote:
Originally Posted by mansonh
Yah the issue with your code was that you were doing an
if() asdasd;
{

you can end an if statement with ; and use a { at the same time.
Huh? lol


Re: Whats wrong with this? - mansonh - 07.02.2010


//Here your end your if statement in one line
if(strcmp(params,"lvpd",true) == 0) return SendClientMessage(playerid,0xFF0000FF,"Usage: /open [gate]");
then right after you try to use a { for the if statement
{

You can either do
if(...) function;
or
if(...)
{
functions
}

Man, I have seen a lot of stuff like this from your posts, please please
https://sampwiki.blast.hk/


Re: Whats wrong with this? - Torran - 07.02.2010

Well if i do it that way,
How would i get it to return SendClientMessage if that gate ( params ) dont exist,
Like if i type /open lvpd, It would work, But if i type /open sfpd, It would say,
This gate dosent exist


Re: Whats wrong with this? - mansonh - 07.02.2010

Well your code doesn't include sfpd, so you wouldn't want sfpd to work.

Rearange your program to work however you want.
But you can't do
if() function;
{


Re: Whats wrong with this? - Torran - 07.02.2010

Im still not understanding you


Re: Whats wrong with this? - MadeMan - 07.02.2010

pawn Код:
dcmd_open(playerid, params[])
{
    if(strcmp(params,"lvpd",true) == 0)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(IsPlayerInRangeOfPoint(playerid, 10.0, 2294.230713, 2499.273682, 5.752781))
            {
                MoveObject(lvgate1,2294.230713, 2507.217041, 5.752781,2);
                SetTimer("LVGates1",9000,0);
            }
            else if(IsPlayerInRangeOfPoint(playerid, 10.0, 2334.719971, 2443.472900, 8.230819))
            {
                MoveObject(lvgate2,2330.758057, 2436.558838, 8.230819,2);
                SetTimer("LVGates2",9000,0);
            }
        }
    }
    else
    {
        SendClientMessage(playerid,0xFF0000FF,"Usage: /open [gate]");
        return 1;
    }
    return 1;
}