How can i make this work ?
#1

In the code provided below when a player types /work and if he's near Area 51 or SF Carrier he gets a checkpoint so if
he's near sf carrier , he should get an message saying fly from sf carrier to a51 and viseversa .
So i've tried to make the code work but it doesn't .
Any suggestions ? :
pawn Код:
if(checkpointid == CP_SFCarrier)
    {
    new string[200];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    new imoney = RandomEx( 10000,30000 );
    format(string,sizeof(string),"[{FFA500}FLIGHT COMPLETED{EEEEEE}]You completed a flight from A51 to SF Carrier and got %d",imoney);
    SendClientMessage(playerid,COLOR_ORANGE,string);
    format(string,sizeof(string),"[{FFA500}ARMY FLIGHT{EEEEEE}%s has completed a military flight from A51 to SF Carrier and got %d",pName,imoney);
    SendClientMessageToAll(COLOR_ORANGE,string);
    }
    if(checkpointid == CP_A51)
    {
    new string[200];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    new imoney = RandomEx( 10000,30000 );
    format(string,sizeof(string),"[{FFA500}FLIGHT COMPLETED{EEEEEE}]You completed a flight from SF Carrier to A51 and got %d",imoney);
    SendClientMessage(playerid,COLOR_ORANGE,string);
    format(string,sizeof(string),"[{FFA500}ARMY FLIGHT{EEEEEE}%s has completed a military flight from SF Carrier to A51 and got %d",pName,imoney);
    SendClientMessageToAll(COLOR_ORANGE,string);
    }

CMD:work(playerid,params[])
{
    if(gTeam[playerid] == TEAM_ARMY)
    {
    if(IsPlayerInRangeOfPoint(playerid,50.0,-1314.2576,498.6849,18.2344))
    {
    CP_SFCarrier = CreateDynamicCP(-1314.2576,498.6849,18.2344,-1,-1,-1,-1,30.0);
    SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from SF Carrier to A51");
    }
    if(IsPlayerInRangeOfPoint(playerid,50.0,311.3356,2049.9468,17.6406))
    {
    CP_A51 = CreateDynamicCP(311.3356,2049.9468,17.6406,-1,-1,-1,-1,50.0);
    SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from A51 to SF Carrier");
    }
    }
    return 1;
}
Well ofcourse i dont get any errors , its just that the code is not right .
What i wanted it to do :
When he is in sf carrier he gets a cp to sf carrier and when he enters it he gets a cp to a51 and viseversa .
Reply
#2

Bump .
Reply
#3

hello at first try this

PHP код:
CMD:work(playerid,params[])
{
    if(
gTeam[playerid] == TEAM_ARMY)
    {
    if(
IsPlayerInRangeOfPoint(playerid,50.0,-1314.2576,498.6849,18.2344))
    {
    
CP_SFCarrier CreateDynamicCP(311.3356,2049.9468,17.6406,-1,-1,-1,-1,30.0);
    
SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from SF Carrier to A51");
    }
    if(
IsPlayerInRangeOfPoint(playerid,50.0,311.3356,2049.9468,17.6406))
    {
    
CP_A51 CreateDynamicCP(-1314.2576,498.6849,18.2344,-1,-1,-1,-1,50.0);
    
SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from A51 to SF Carrier");
    }
    }
    return 
1;

Reply
#4

Quote:
Originally Posted by yusei
Посмотреть сообщение
hello at first try this

PHP код:
CMD:work(playerid,params[])
{
    if(
gTeam[playerid] == TEAM_ARMY)
    {
    if(
IsPlayerInRangeOfPoint(playerid,50.0,-1314.2576,498.6849,18.2344))
    {
    
CP_SFCarrier CreateDynamicCP(311.3356,2049.9468,17.6406,-1,-1,-1,-1,30.0);
    
SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from SF Carrier to A51");
    }
    if(
IsPlayerInRangeOfPoint(playerid,50.0,311.3356,2049.9468,17.6406))
    {
    
CP_A51 CreateDynamicCP(-1314.2576,498.6849,18.2344,-1,-1,-1,-1,50.0);
    
SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from A51 to SF Carrier");
    }
    }
    return 
1;

its the same code lol .
Reply
#5

if you are trying to check if player is in CP use this function

native IsPlayerInDynamicCP(playerid, checkpointid);
Reply
#6

Quote:

its the same code lol .

lool, no see your cmd

Код:
CMD:work(playerid,params[])
{
    if(gTeam[playerid] == TEAM_ARMY)
    {
    if(IsPlayerInRangeOfPoint(playerid,50.0,-1314.2576,498.6849,18.2344))
    {
    CP_SFCarrier = CreateDynamicCP(-1314.2576,498.6849,18.2344,-1,-1,-1,-1,30.0);
    SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from SF Carrier to A51");
    }
    if(IsPlayerInRangeOfPoint(playerid,50.0,311.3356,2049.9468,17.6406))
    {
    CP_A51 = CreateDynamicCP(311.3356,2049.9468,17.6406,-1,-1,-1,-1,50.0);
    SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from A51 to SF Carrier");
    }
    }
    return 1;
}
Mine is ;

Код:
CMD:work(playerid,params[]) 
{ 
    if(gTeam[playerid] == TEAM_ARMY) 
    { 
    if(IsPlayerInRangeOfPoint(playerid,50.0,-1314.2576,498.6849,18.2344)) 
    { 
    CP_SFCarrier = CreateDynamicCP(311.3356,2049.9468,17.6406,-1,-1,-1,-1,30.0); 
    SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from SF Carrier to A51"); 
    } 
    if(IsPlayerInRangeOfPoint(playerid,50.0,311.3356,2049.9468,17.6406)) 
    { 
    CP_A51 = CreateDynamicCP(-1314.2576,498.6849,18.2344,-1,-1,-1,-1,50.0); 
    SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from A51 to SF Carrier"); 
    } 
    } 
    return 1; 
}
Reply
#7

Nope..
Create the checkpoints inside OnGameModeInit,(Make sure you defined the cp's (new CP_SFCarrier; and CP_A51; ) for example:
pawn Код:
public OnGameModeInit()
{
CP_SFCarrier = CreateDynamicCP(-1314.2576,498.6849,18.2344,-1,-1,-1,-1,30.0);
CP_A51 = CreateDynamicCP(-1314.2576,498.6849,18.2344,-1,-1,-1,-1,50.0);
return 1;
}
Next, To use the /work command:
pawn Код:
CMD:work(playerid,params[])
{
    if(gTeam[playerid] == TEAM_ARMY)
        {
            if(IsPlayerInDynamicCP(playerid,CP_SFCarrier))
            {
            SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from SF Carrier to A51");
            }
            if(IsPlayerInDynamicCP(playerid,CP_A51))
            {
            SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from A51 to SF Carrier");
            }
        }
    return 1;
}
Failed spaces, Sorry, i'm on my android..
Try this.
Reply
#8

pawn Код:
CMD:work(playerid,params[])
{
    if(gTeam[playerid] == TEAM_ARMY)
    {
    new Float:d1,Float:d2;
    d1=GetPlayerDistanceFromPoint(playerid,-1314.2576,498.6849,18.2344);
    d2=GetPlayerDistanceFromPoint(playerid,311.3356,2049.9468,17.6406);
    if(d1<d2)
    {
    CP_SFCarrier = CreateDynamicCP(-1314.2576,498.6849,18.2344,-1,-1,-1,-1,30.0);
    SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from SF Carrier to A51");
    }
    if(d2<d1)
    {
    CP_A51 = CreateDynamicCP(311.3356,2049.9468,17.6406,-1,-1,-1,-1,50.0);
    SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from A51 to SF Carrier");
    }
    }
    return 1;
}
this^
Reply
#9

Well thank you all but the /work command isn't the problem . I dont want the checkpoints defined under ongamemodeinit because i dont want them to be on all the time.
Here's how i thought it would work:
When a player is near sf carrier and he types /work he gets a checkpoint in sf carrier.When he enters it , he gets the message saying to fly to a51 . When he enters a51 he gets paid . When he types /work again , since he's in a51 he gets a cp to a51 and a message to fly to sf carrier . As i said , i dont get errors and the problem is under OnPlayerEnterDynamicCP
Reply
#10

Ah ok ^^

you can use a variables example

PHP код:
new boolvar0[MAX_PLAYERS];
new 
boolvar1[MAX_PLAYERS];
if(
checkpointid == CP_SFCarrier)
{
    if(
var0[playerid] == false)    {  CP_A51 CreateDynamicCP(311.3356,2049.9468,17.6406,-1,-1,-1,-1,50.0);  var0[playerid] = true; break; }
    if(
var1[playerid] != false)    {
    new 
string[200];
    new 
pName[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    new 
imoney RandomEx10000,30000 );
    
format(string,sizeof(string),"[{FFA500}FLIGHT COMPLETED{EEEEEE}]You completed a flight from A51 to SF Carrier and got %d",imoney);
    
SendClientMessage(playerid,COLOR_ORANGE,string);
    
format(string,sizeof(string),"[{FFA500}ARMY FLIGHT{EEEEEE}%s has completed a military flight from A51 to SF Carrier and got %d",pName,imoney);
    
SendClientMessageToAll(COLOR_ORANGE,string);
    }
}
if(
checkpointid == CP_A51)
{
    if(
var1[playerid] == false)    {  CP_SFCarrier CreateDynamicCP(-1314.2576,498.6849,18.2344,-1,-1,-1,-1,30.0);  var1[playerid] = true; break; }
    if(
var0[playerid] != false)    {
    new 
string[200];
    new 
pName[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    new 
imoney RandomEx10000,30000 );
    
format(string,sizeof(string),"[{FFA500}FLIGHT COMPLETED{EEEEEE}]You completed a flight from SF Carrier to A51 and got %d",imoney);
    
SendClientMessage(playerid,COLOR_ORANGE,string);
    
format(string,sizeof(string),"[{FFA500}ARMY FLIGHT{EEEEEE}%s has completed a military flight from SF Carrier to A51 and got %d",pName,imoney);
    
SendClientMessageToAll(COLOR_ORANGE,string);
    }
}
CMD:work(playerid,params[])
{
    if(
gTeam[playerid] == TEAM_ARMY)
    {
        if(
IsPlayerInRangeOfPoint(playerid,50.0,-1314.2576,498.6849,18.2344))
        {
            
var0[playerid] = false;
            
CP_SFCarrier CreateDynamicCP(-1314.2576,498.6849,18.2344,-1,-1,-1,-1,30.0);
            
SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from SF Carrier to A51");
        }
        if(
IsPlayerInRangeOfPoint(playerid,50.0,311.3356,2049.9468,17.6406))
        {
            
var1[playerid] = false;
            
CP_A51 CreateDynamicCP(311.3356,2049.9468,17.6406,-1,-1,-1,-1,50.0);
            
SendClientMessage(playerid,COLOR_ORANGE,"[{FFA500}FLIGHT{EEEEEE}]Complete a flight from A51 to SF Carrier");
        }
    }
    return 
1;

PS : failed Break must be return true;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)