Creating a command that lists all dynamic'ly created teleports?
#1

I have created a dynamic teleport system and it consist of the ability to create teleport commands (You have the powers to modify the command name for that teleport as well... Change the teleport position... etc)

Now the question is..

How can I list all the teleport commands I have made like when I typed /teles it will show up like this

Код:
Las Venturas (/lv)
Los Santos (/ls)
San Fierro (/sf)
Drag Race (/drag)
Place One (/place1)
Place Two (/place2)
Place Three (/place3)
8 Track (/8track)
Cloud Nine (/c9)
Next ->
Then when it exceeds above nine command teleports+ a button "Next ->" will show up, when that button is pressed a new set of list next to Cloud Nine will show up.

I wanted to script it but I really don't know how or where to get started. I am using SQLite.

g_Teleport[teleport_id][e_Command] <- The command name enum holder.

Any help will be appreciated.
Reply
#2

If your using Dialog then:
Quote:

Las Venturas (/lv)\nLos Santos (/ls)\nSan Fierro (/sf)\nDrag Race (/drag)\nPlace One (/place1)\nPlace Two (/place2)\nPlace Three (/place3)\n8 Track (/8track)\nCloud Nine (/c9)\n
Next ->

if your using textdraws then here: https://sampforum.blast.hk/showthread.php?tid=328267
Reply
#3

Quote:
Originally Posted by Joron
Посмотреть сообщение
If your using Dialog then:

if your using textdraws then here: https://sampforum.blast.hk/showthread.php?tid=328267
How ironic that a few minutes ago I saw you posting down something at Crayder's thread and you didn't red the whole thread and you did the same on my topic.

I have clearly state on my title "dynamic'ly" not "manually".

I still appreciated your help though even though you are trying.
Reply
#4

Have you got an enum for them? Or, how do you define them?

Edit: Just saw your enum definition. Can you show the full enum please?
Reply
#5

Quote:
Originally Posted by JaKe Elite
Посмотреть сообщение
How ironic that a few minutes ago I saw you posting down something at Crayder's thread and you didn't red the whole thread and you did the same on my topic.

I have clearly state on my title "dynamic'ly" not "manually".

I still appreciated your help though even though you are trying.
I figured that u already know this,yet i posted....when someone gives u the answer wouldnt i learn something new today? Ok.
Reply
#6

Quote:
Originally Posted by Joron
Посмотреть сообщение
I figured that u already know this,yet i posted....when someone gives u the answer wouldnt i learn something new today? Ok.
Why would I post this thread If I already know how to create it? Refresh your mind and take a day off of SA-MP Forums so the next time you came back you'd understand what is happening around you. You clearly don't know what is the difference between manual and dynamic. Post down below if you wanted to continue but I wouldn't reply on you anymore, I don't wanna turn this into a thread with full of arguments.

Edit:

@iGetty

PHP код:
#define     MAX_TELEPORTS       (100)
enum E_TELEPORT_ENUM
{
    
e_Command[10],
    
e_TeleportName[32],
    
Float:e_onFootX,
    
Float:e_onFootY,
    
Float:e_onFootZ,
    
Float:e_onFootA,
    
Float:e_vehicleX,
    
Float:e_vehicleY,
    
Float:e_vehicleZ,
    
Float:e_vehicleA,
    
e_teleportInterior,
    
e_teleportWorld,
    
e_teleportFreeze
};
new 
g_Teleport[MAX_TELEPORTS][E_TELEPORT_ENUM]; 
Finally I was waiting for your response. I need people like you who can clearly understands my situation.
Reply
#7

Good Job
Reply
#8

pawn Код:
#include <a_samp>
#include <zcmd>

enum _cp{
    e_ID,
    e_Command,
    e_TeleportName
}
new g_Teleport[1000][_cp];


new lastCPCheck[MAX_PLAYERS];

#define DIALOG_TELES    1

public OnPlayerConnect(playerid){
    lastCPCheck[playerid] = 0;
    return 1;
}

CMD:teles(playerid, params[]){
    new count=0, longstr[1000];
    for(new i = 0; i < 9; i++){
        if(strlen(g_Teleport[i][e_Command]) > 0){
            count++;
           
            format(longstr, sizeof(longstr), "%s%s (/%s)\n", longstr, g_Teleport[i][e_TeleportName], g_Teleport[i][e_Command]);        
            lastCPCheck[playerid] = i;
        }
   
    }
   
    if(!count)return SendClientMessage(playerid, -1, "No teleport commands available.");
   
    if(count < 9){
        ShowPlayerDialog(playerid, DIALOG_TELES, DIALOG_STYLE_LIST, "Teleport Commands", longstr, "", "Close");
    }
    else{
        ShowPlayerDialog(playerid, DIALOG_TELES, DIALOG_STYLE_LIST, "Teleport Commands", longstr, "", "-> Next");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
    switch(dialogid){
        case DIALOG_TELES:{
            if(response)return 1;
            else{
                new longstr[1000], id = lastCPCheck[playerid], count=id;
               
                for(new i = id; i < id+9; i++){
                    if(strlen(g_Teleport[i][e_Command]) > 0){
                        count++;
               
                        format(longstr, sizeof(longstr), "%s%s (/%s)\n", longstr, g_Teleport[i][e_TeleportName], g_Teleport[i][e_Command]);
                   
                        lastCPCheck[playerid] = i;
                    }
                }
                if(count < lastCPCheck[playerid]+9){
                    ShowPlayerDialog(playerid, DIALOG_TELES, DIALOG_STYLE_LIST, "Teleport Commands", longstr, "", "Close");
                }
                else{
                    ShowPlayerDialog(playerid, DIALOG_TELES, DIALOG_STYLE_LIST, "Teleport Commands", longstr, "", "-> Next");
                }
            }
        }
    }
    return 1;
}
I've gotten there for you, I've adjusted a few things to make it easier for me to read (enum etc) - Don't need to re-add it on your end, just add the CMD, variable and dialog stuff.

Untested, but I don't see why it wouldn't work
Reply
#9

Quote:
Originally Posted by iGetty
Посмотреть сообщение
pawn Код:
#include <a_samp>
#include <zcmd>

enum _cp{
    e_ID,
    e_Command,
    e_TeleportName
}
new g_Teleport[1000][_cp];


new lastCPCheck[MAX_PLAYERS];

#define DIALOG_TELES    1

public OnPlayerConnect(playerid){
    lastCPCheck[playerid] = 0;
    return 1;
}

CMD:teles(playerid, params[]){
    new count=0, longstr[1000];
    for(new i = 0; i < 9; i++){
        if(strlen(g_Teleport[i][e_Command]) > 0){
            count++;
           
            format(longstr, sizeof(longstr), "%s%s (/%s)\n", longstr, g_Teleport[i][e_TeleportName], g_Teleport[i][e_Command]);        
            lastCPCheck[playerid] = i;
        }
   
    }
   
    if(!count)return SendClientMessage(playerid, -1, "No teleport commands available.");
   
    if(count < 9){
        ShowPlayerDialog(playerid, DIALOG_TELES, DIALOG_STYLE_LIST, "Teleport Commands", longstr, "", "Close");
    }
    else{
        ShowPlayerDialog(playerid, DIALOG_TELES, DIALOG_STYLE_LIST, "Teleport Commands", longstr, "", "-> Next");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){
    switch(dialogid){
        case DIALOG_TELES:{
            if(response)return 1;
            else{
                new longstr[1000], id = lastCPCheck[playerid], count=id;
               
                for(new i = id; i < id+9; i++){
                    if(strlen(g_Teleport[i][e_Command]) > 0){
                        count++;
               
                        format(longstr, sizeof(longstr), "%s%s (/%s)\n", longstr, g_Teleport[i][e_TeleportName], g_Teleport[i][e_Command]);
                   
                        lastCPCheck[playerid] = i;
                    }
                }
                if(count < lastCPCheck[playerid]+9){
                    ShowPlayerDialog(playerid, DIALOG_TELES, DIALOG_STYLE_LIST, "Teleport Commands", longstr, "", "Close");
                }
                else{
                    ShowPlayerDialog(playerid, DIALOG_TELES, DIALOG_STYLE_LIST, "Teleport Commands", longstr, "", "-> Next");
                }
            }
        }
    }
    return 1;
}
I've gotten there for you, I've adjusted a few things to make it easier for me to read (enum etc) - Don't need to re-add it on your end, just add the CMD, variable and dialog stuff.

Untested, but I don't see why it wouldn't work
Sweet, Gonna try it out! Thank you I will be updating you the status of the code if it is working or not.

Edit:

I have noticed that the Close Button is looping when pressed. (You will be brought back to the dialog again, You have to press the other emptied button to exit the dialog). I will be fixing it myself however how can I make the players teleport to that location if the player clicked it?

Edit 2:

The 8th teleport command shows up in the second page and when I pressed the back button while in the second page, It will just redirect me to the very last bottom command list.
Reply
#10

I'll fix it, sec.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)