Problem with loadiron command.
#1

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

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

Reply
#3

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)