Whats wrong with this?
#1

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?
Reply
#2

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;
}
Reply
#3

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

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.
Reply
#5

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
Reply
#6


//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/
Reply
#7

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
Reply
#8

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;
{
Reply
#9

Im still not understanding you
Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)