Help me out!
#1

Alright so i have this system which helps me create checkpoints without adding 1 line for each "CreateDynamicCP"

pawn Код:
enum checkCPinfo
{
    cpID,
    Float:x,
    Float:y,
    Float:z,
    Float:cpSize,
    Float:ViewDistance
}

//rest of the code

static const server_CreateCheckpoints[][checkCPinfo] =
{
        {1,2159.2742,943.1719,10.8203,1.0,100.0},//Ammunation 4Dragons Entrance
        {2,2539.4631,2084.0339,10.8203,1.0,100.0},//Ammunation Emerald Isle Entrance
        {3,2286.9143,2432.3669,10.8203,1.0,100.0},//LVPD Entrance
        {4,285.7855,-86.7201,1001.5229,1.0,100.0}//Ammunation 4Dragons Exit
        /*{5,2286.8674,2431.7437,10.8203,1.0,100.0},
        {6,238.7121,139.5305,1003.0234,1.0,100.0}*/

};

stock server_CreateAllCheckpoints()
{
        for(new i; i < sizeof(server_CreateCheckpoints); i++)
        {
                CreateDynamicCP(server_CreateCheckpoints[i][x],server_CreateCheckpoints[i][y],server_CreateCheckpoints[i][z],server_CreateCheckpoints[i][cpSize],-1,-1,-1,server_CreateCheckpoints[i][ViewDistance]);
        }
        return 1;
}


public OnPlayerEnterDynamicCP(playerid,checkpointid)
{
    for(new i=0; i < sizeof(server_CreateCheckpoints); i++) //
        {
                if(server_CreateCheckpoints[i][cpID] == 0)//Ammunation 4Dragons Entrance
                {
                        SetPlayerPos(playerid,286.4219,-82.7033,1001.5156);
                        SetPlayerFacingAngle(playerid,293.4572);
                        SetCameraBehindPlayer(playerid);
                        SetPlayerInterior(playerid,4);
                }
The problem is that when i enter a checkpoints,no matter which one, it does what it supposed to do on the last one.
As you noticed they are numbered. TO make it clear...When i enter checkpoint 1 or 2 it does what it was supposed to do when i was entering checkpoint 3.
Reply
#2

{1,2159.2742,943.1719,10.8203,1.0,100.0},//Ammunation 4Dragons Entrance

if(server_CreateCheckpoints[i][cpID] == 0)//Ammunation 4Dragons Entrance

The number 1 and 0 is two different ones. Is that maybe the problem ?
Reply
#3

Quote:
Originally Posted by airplanesimen
Посмотреть сообщение
{1,2159.2742,943.1719,10.8203,1.0,100.0},//Ammunation 4Dragons Entrance

if(server_CreateCheckpoints[i][cpID] == 0)//Ammunation 4Dragons Entrance

The number 1 and 0 is two different ones. Is that maybe the problem ?
Nope,that's not the problem!
But thanks for the heads up.
Reply
#4

well ur code , there is a problem ,
see that function gets call when u enter a cp [that can be any(server sided)]
So ur loop here makes no Sense at all
cuz element at i will always have cpID = 'WhatUWanted' , therefore if ur loop starts from 0 and it will do what it is supposed to do at cpID = 1, then 'if u have a elseif check' in second time when i = 1, it will again do what it is supposed to do at cpID = 2 (as element at 1 of array has cpID as 2 )

^ actually i am failing to explain but ur loop here is all wrong

what u should do is rather is add a element to ur enum call it ' serverCPiD '

pawn Код:
stock server_CreateAllCheckpoints()
{
        for(new i; i < sizeof(server_CreateCheckpoints); i++)
        {
                server_CreateCheckpoints[i][serverCPiD] = CreateDynamicCP(server_CreateCheckpoints[i][x],server_CreateCheckpoints[i][y],server_CreateCheckpoints[i][z],server_CreateCheckpoints[i][cpSize],-1,-1,-1,server_CreateCheckpoints[i][ViewDistance]);
        }
        return 1;
}

//--- later
public OnPlayerEnterDynamicCP(playerid,checkpointid)
{
       for(new i=0; i < sizeof(server_CreateCheckpoints); i++) //
        {
                if(server_CreateCheckpoints[i][serverCPiD] == checkpointid)
                {
                    switch(  server_CreateCheckpoints[i][cpID] )
                   {
                        case 1:
                       {
// do for cpID =  1
                       }
                       case 2:
                       {
// do for cpID =  2
                       }
//and so on..
                   }
                   break; // not necessarily needed here
               }  
       }
}
Reply
#5

Alright thanks Niko,i'll test it out and leave a reply if it worked or not.

EDIT: Yup it works,thanks alot for the explanation.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)