SA-MP Forums Archive
Problem with loadiron 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: Problem with loadiron command. (/showthread.php?tid=483354)



Problem with loadiron command. - R4mpage - 25.12.2013

Well, I was making a command called /loadiron so at my survival server you can load in iron that came from warehouses to your Backpack, I used IsPlayerInRangeOfPoint, but it ain't functioning right, since when I aint at the position i used at IsPlayerInRangeOfPoint even tho i use /loadiron it still loads while i used else
but here the code when i use other cmds it says You are not at the warehouse, while i didnt script like "when i use /stats it shows under stats You are not at the Warehouse


pawn Код:
if (strcmp("/loadiron", cmdtext,true,10) == 0)
    {
    IsPlayerInRangeOfPoint(playerid,2.0,-2454.5771,2254.1755,4.9802);
    PlayerInfo[playerid][pIron]++;
    PlayerInfo[playerid][pIron]++;
    PlayerInfo[playerid][pIron]++;
    PlayerInfo[playerid][pIron]++;
    PlayerInfo[playerid][pIron]++;
    SendClientMessage(playerid,COLOR_PURPLE,"You Have Loaded In 5 Pieces of Iron!");
    }
    else
    {
    !IsPlayerInRangeOfPoint(playerid,2.0,-2454.5771,2254.1755,4.9802);
    SendClientMessage(playerid,COLOR_RED,"You are not at the warehouse!");
    return 1;
    }



Re: Problem with loadiron command. - CutX - 25.12.2013

Quote:
Originally Posted by R4mpage
Посмотреть сообщение
pawn Код:
IsPlayerInRangeOfPoint(playerid,2.0,-2454.5771,2254.1755,4.9802);

you have to put it in an "if statement"
esample:

PHP код:
if(IsPlayerInRangeOfPoint(playerid,2.0,-2454.5771,2254.1755,4.9802))//this is when he's in range of that point

//do something
}
if(!
IsPlayerInRangeOfPoint(playerid,2.0,-2454.5771,2254.1755,4.9802))//and this with the " ! " when hes not

//do something
}
//or just:
if(IsPlayerInRangeOfPoint(playerid,2.0,-2454.5771,2254.1755,4.9802))//this is when he's in range of that point

//do something
}
else
//when the first condition equals "false"
{
//do something when hes not




Re: Problem with loadiron command. - PrivatioBoni - 25.12.2013

1. You're missing an if for the IsPlayerInRange
2. The curly brackets are the wrong way around (in regards to the else). The one above the else should be "{", and below it should be "}"

That's all I can see for now.


Re: Problem with loadiron command. - R4mpage - 25.12.2013

If i change brackets it give this error:
C:\Users\Eigenaar\Documents\Erdem\2\gamemodes\DayZ .pwn(399) : error 029: invalid expression, assumed zero


Re: Problem with loadiron command. - CutX - 25.12.2013

here you go, copy & paste style >.>

PHP код:
if (strcmp("/loadiron"cmdtext,true,10) == 0)
{
    if(!
IsPlayerInRangeOfPoint(playerid,2.0,-2454.5771,2254.1755,4.9802)) return SendClientMessage(playerid,COLOR_RED,"You are not at the warehouse!");
    
PlayerInfo[playerid][pIron]++;
    
PlayerInfo[playerid][pIron]++;
    
PlayerInfo[playerid][pIron]++;
    
PlayerInfo[playerid][pIron]++;
    
PlayerInfo[playerid][pIron]++;
    
SendClientMessage(playerid,COLOR_PURPLE,"You Have Loaded In 5 Pieces of Iron!");
    return 
1;

i'd suggest you checkout that site: https://sampwiki.blast.hk/wiki/Control_Structures


Re: Problem with loadiron command. - Sanady - 25.12.2013

Maybe this too.
pawn Код:
PlayerInfo[playerid][pIron]++;
    PlayerInfo[playerid][pIron]++;
    PlayerInfo[playerid][pIron]++;
    PlayerInfo[playerid][pIron]++;
    PlayerInfo[playerid][pIron]++;
Change to
pawn Код:
PlayerInfo[playerid][pIron] += 5;
It should save some lines