Simple teleport processor with zcmd?
#1

Hello

In a GM I made long ago I made an easy-to-use and line saving teleport system.
Here's what I did:
pawn Код:
enum TeleportInfo
{
    tType,
    tTele[128],
    tName[128],
    Float:tx,
    Float:ty,
    Float:tz,
    Float:tAngle_P,
    bool:tVehicleRemove,
    tTimeH,
    tTimeM,
    tWeapon,
    tAmmo,
    Float:tx_V,
    Float:ty_V,
    Float:tz_V,
    Float:tAngle_V,
    tUsed,
}

new tInfo[40][TeleportInfo] =
{
    {TYPE_STUNT, "/hh", "Huge Halfpipe", -1252.8372802734,-3572.2570800781,19.23807144165, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // hh
    {TYPE_STUNT, "/hh2", "Huge HalfPipe 2", -966.3057,2704.9131,43.8409, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // hh2
    {TYPE_STUNT, "/chilliad", "MT Chilliad", -2358.1282,-1631.2905,486.5476, 0.0, true, 12, 0, 46, 1, 0.0, 0.0, 0.0, 0.0, 0}, // chilliad
    {TYPE_STUNT, "/coaster", "Coaster 1", 3394.7490234375,-2858.6318359375,586.51507568359, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // coaster
    {TYPE_STUNT, "/lvsz", "North Las Venturas Stuntzone", 2955.1484375,2718.0791015625,47.445892333984, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // lvsz
    {TYPE_STUNT, "/ej", "Evel Knievel Jump", 830.79907226563,-1649.3950195313,96.727676391602, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // ej
    {TYPE_STUNT, "/lvsky", "Las Venturas Sky Park", 2050.4905,2047.7407,304.1125, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // lvksy
    {TYPE_STUNT, "/pj", "Pier Jump", 354.1863,-760.6149,871.6344, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // pj
    {TYPE_STUNT, "/cj", "Coast Jump", 404.13891601563,-2888.9594726563,751.1493530273, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // cj
    {TYPE_STUNT, "/da", "Desert Airport", 419.800018, 2531.705322, 16.157726, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // da
    {TYPE_STUNT, "/coaster2", "Coaster 2", 35.38744354248,-900.32940673828,1761.6329345703, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // coaster2
    {TYPE_STUNT, "/canyon", "Canyon Jump", -672.6729,2311.8418,134.7830, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // canyon
    {TYPE_STUNT, "/farm", "Farm StuntPark", -1011.8487548828,-1024.7260742188,129.01875305176, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // farm
    {TYPE_STUNT, "/dam", "The Dam", -528.1,2129.4,45.3, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // dam
    {TYPE_STUNT, "/paradise", "Stunt Paradise", 2437.7554,-3492.3938,6.1205, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // paradise
    {TYPE_STUNT, "/hd", "Heavens Drop", 3425.0229,-1048.2330,1465.5647, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // hd
//------------------------------------------------------------------------------
    {TYPE_RACE, "/driftcity", "Drift City", -1025.1023,1019.2966,2.9941, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // driftcity
    {TYPE_RACE, "/kart", "Kart Race", 2570.8005,1893.9918,10.8280, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // kart
    {TYPE_RACE, "/drag2", "Drag Race 2", 2041.580688,-3113.884277,6.142639, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // drag2
//------------------------------------------------------------------------------
    {TYPE_NRG, "/nrg", "Nrg course 1", 2784.3462,-2518.5698,13.6319, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // nrg
    {TYPE_NRG, "/nrg2", "Nrg course 2", 2798.9404,-1643.3833,28.5625, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // nrg
//------------------------------------------------------------------------------
    {TYPE_BACKFLIP, "/backflip", "Oil BackFlip, do not turn left or right!", 151.1787109375, 1339.357421875, 10.246315002441, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // backflip
//------------------------------------------------------------------------------
    {TYPE_BASEJUMP, "/jump1", "Base Jump 1", 1961.4845,1920.7383,131.1122, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // jump
    {TYPE_BASEJUMP, "/jump2", "Base Jump 2", 1562.7367,-1346.4706,330.0493, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // jump
    {TYPE_BASEJUMP, "/jump3", "Base Jump 3", 1592.8718,-1221.6572,278.0506, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // jump
    {TYPE_BASEJUMP, "/jump4", "Base Jump 4", 1661.2975,-1247.3594,233.9873, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // jump
    {TYPE_BASEJUMP, "/jump5", "Base Jump 5", 1436.8242,-1053.2672,213.8473, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // jump
    {TYPE_BASEJUMP, "/jump6", "Base Jump 6", -861.6122,2307.6626,159.9215, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // jump
    {TYPE_BASEJUMP, "/jump7", "Base Jump 7", -755.6661,2041.5369,83.1339, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // jump
    {TYPE_BASEJUMP, "/jump8", "Base Jump 8", -1280.3628,978.4018,148.2734, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // jump
    {TYPE_BASEJUMP, "/jump9", "Base Jump 9", -1668.3292,884.1396,138.3281, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // jump
    {TYPE_BASEJUMP, "/jump10", "Base Jump 10", -1807.4314,574.6566,245.9893, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // jump
    {TYPE_BASEJUMP, "/jump11", "Base Jump 11", -2669.7974,1595.3375,217.2739, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // jump
//------------------------------------------------------------------------------
    {TYPE_OTHER, "/babel", "The BabelTower", 1544.5788574219,-1399.7844238281,342.79623413086, 0.0, true, 12, 0, 46, 1, 0.0, 0.0, 0.0, 0.0, 0}, // babel
    {TYPE_OTHER, "/bounce", "Trampoline", 1977.0219726563,-1272.712890625,4363.1166992188, 0.0, false, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // bounce
    {TYPE_OTHER, "/bowl", "Huge Glass Bowl", -219.1842,-618.2765,117.4826, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // bowl
    {TYPE_OTHER, "/cannon", "The Cannon", -556.0517,2580.0288,65.8368, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // cannon
    {TYPE_OTHER, "/island", "Chill-Island", 261.1905,-3271.4392,5.7316, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // island
    {TYPE_OTHER, "/pd", "Parachute Drop", 3075.26,-2053.21,355.5, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0}, // pd
    {TYPE_OTHER, "/pipe", "Pipes", 2672.00830100,-1076.75427200,301.88580300, 0.0, true, 12, 0, -1, -1, 0.0, 0.0, 0.0, 0.0, 0} // pipe
};

new TeleportList[MAX_PLAYERS][sizeof(tInfo)];
And then:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

    for(new i; i<sizeof(tInfo); i++)
    {
        if(!strcmp(tInfo[i][tTele], cmdtext, true))
        {
            AddPlayerTeleport(playerid, tInfo[i][tName], tInfo[i][tx], tInfo[i][ty], tInfo[i][tz], tInfo[i][tTimeH], tInfo[i][tTimeM], tInfo[i][tVehicleRemove], tInfo[i][tWeapon], tInfo[i][tAmmo]);
            tInfo[i][tUsed]++;
            return 1;
        }
    }
//More stuff
However, in this GM, I would like to leave everything under OnPlayerCommandText empty and use zcmd only, but how can I get this:
pawn Код:
if(!strcmp(tInfo[i][tTele], cmdtext, true))
To work for zcmd?
so that I do not need to make a command for each teleport, but one command for each teleport?

Thanks in advance
Reply
#2

You can simply do:
pawn Код:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
    if( !success )
    {
        for( new t = 0; t < sizeof( tInfo ); t++ )
        {
            if( !strcmp( cmdtext, tInfo[ i ][ tTele ], true ) )
            {
                // Teleport, give weapons etc..
                break;
            }
        }
    }
    return 1;
}
Or in case you want a custom message instead of "SERVER: Unknown command", you can use:
pawn Код:
public OnPlayerCommandPerformed( playerid, cmdtext[ ], success )
{
    if( !success )
    {
        new
            bool: exists = false
        ;
        for( new t = 0; t < sizeof( tInfo ); t++ )
        {
            if( !strcmp( cmdtext, tInfo[ i ][ tTele ], true ) )
            {
                // Teleport, give weapons etc..
                exists = true;
                break;
            }
        }
        if( !exists ) SendClientMessage( playerid, 0xFF0000FF, "That command does not exist." );
    }
    return 1;
}
Reply
#3

Thanks man
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)