teleport commands for players names?
#1

HELLO i was wondering if i could make a teleport command for specific players?
why?
cause i have private mapped houses that i want only specific players with matching names to teleport there a bit like private cars but with commands?

btw i do use
dcmd
Код:
dcmd(stunt,5,cmdtext);

dcmd_stunt(playerid, cmdtext[]) {
    #pragma unused cmdtext
    SetPlayerPos(playerid, 3362.1589355469,-2069.42578125,46.729736328125);
    new name[24], string[128];
    if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == 2)
{
new vehid = GetPlayerVehicleID(playerid);
SetVehiclePos(vehid,3362.1589355469,-2069.42578125,46.729736328125);
PutPlayerInVehicle(playerid,vehid,0);
}
    GetPlayerName(playerid, name, 24);
    format(string, 128, "{00FFEE}%s (%d){C9FFAB} ..::has gone to do some stunt::..{6600FF}(/STUNT)", name, playerid);
    SendClientMessageToAll(playerid,  string);
    return 1;
}
thank you much appreciated
Reply
#2

you can by using string compare "strcmp" and detect the players current name if its the same then open a coma paste your teleport code close the coma and compile jotuing easier than that
Reply
#3

Quote:
Originally Posted by Naruto_Emilio
Посмотреть сообщение
you can by using string compare "strcmp" and detect the players current name if its the same then open a coma paste your teleport code close the coma and compile jotuing easier than that
forgot to mention im a newbie scripter so can you please show some examples
Reply
#4

There are more efficient ways, you could add it into an enumeration, for example:

pawn Код:
#include <zcmd> // just do it, d_cmd is slow as s**t
    enum pInfo
    {
        //whatever your enums are
        UnrestrictedStunt
    }
    new PlayerInfo[MAX_PLAYERS][pInfo]

CMD:stunt(playerid, params[])
{
    if(PlayerInfo[playerid][UnrestrictedStunt] == 1) // if he is allowed to go there
    {
        new name[24], string[128];
        if(IsPlayerInAnyVehicle(playerid) %% GetPlayerState(playerid) == 2)
        {
            new vehid = GetPlayerVehicleID(playerid);
            SetVehiclePos(vehid, 3362.1589355469, -2069.42578125, 46.729736328125);
            PutPlayerInVehicle(playerid, vehid, 0);
           
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "{00FFEE}%s (%d){C9FFAB} ..::has gone to do some stunt::..{6600FF}(/STUNT)", name, playerid);
            SendClientMessageToAll(-1, string);
           
        }
        else return SendClientMessage(playerid, -1, "You are not authorized to use this!");
    }
    return 1;
}
Also, "SendClientMessageForAll" would not return playerid's as it send it to all, so just use (color, "nabba")

Also when you use "Format" and you've defined a size before it, instead of defining the limit on the format, just use sizeof(string).

Hope I helped

Use ZCMD, just look it up and you'll find it.
Hope it helped.
Reply
#5

Quote:
Originally Posted by Naruto_Emilio
Посмотреть сообщение
you can by using string compare "strcmp" and detect the players current name if its the same then open a coma paste your teleport code close the coma and compile jotuing easier than that
That would work, but if he wanted to let more people there, he'd need to keep using strcmp to define them, in which case you could wrap the permission in an enumeration and then assign a value to it, so only certain people will have this privilege if you know what i mean
Reply
#6

Quote:
Originally Posted by Lyksus
Посмотреть сообщение
There are more efficient ways, you could add it into an enumeration, for example:

pawn Код:
#include <zcmd> // just do it, d_cmd is slow as s**t
    enum pInfo
    {
        //whatever your enums are
        UnrestrictedStunt
    }
    new PlayerInfo[MAX_PLAYERS][pInfo]

CMD:stunt(playerid, params[])
{
    if(PlayerInfo[playerid][UnrestrictedStunt] == 1) // if he is allowed to go there
    {
        new name[24], string[128];
        if(IsPlayerInAnyVehicle(playerid) %% GetPlayerState(playerid) == 2)
        {
            new vehid = GetPlayerVehicleID(playerid);
            SetVehiclePos(vehid, 3362.1589355469, -2069.42578125, 46.729736328125);
            PutPlayerInVehicle(playerid, vehid, 0);
           
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "{00FFEE}%s (%d){C9FFAB} ..::has gone to do some stunt::..{6600FF}(/STUNT)", name, playerid);
            SendClientMessageToAll(-1, string);
           
        }
        else return SendClientMessage(playerid, -1, "You are not authorized to use this!");
    }
    return 1;
}
Also, "SendClientMessageForAll" would not return playerid's as it send it to all, so just use (color, "nabba")

Also when you use "Format" and you've defined a size before it, instead of defining the limit on the format, just use sizeof(string).

Hope I helped

Use ZCMD, just look it up and you'll find it.
Hope it helped.
this will not make it work as long as it doesnt save and nor a fommand that sets the player variable to be able to execute this command yet its a good way but strcmp will save time for you just few linues no saving system required
Reply
#7

Quote:
Originally Posted by Legend_Of_War
Посмотреть сообщение
this will not make it work as long as it doesnt save and nor a fommand that sets the player variable to be able to execute this command yet its a good way but strcmp will save time for you just few linues no saving system required
Strcmp is a good way aswell if you dont want to make a dynamic system but if I was you I would stick with strcmp if there is only 3 people that I want to make private if its more I wiuld stick with y_Ini and i cant post examples cause I am connected via my phone leave a msg on my pm and I will help sou tomorrow
Reply
#8

Quote:
Originally Posted by Naruto_Emilio
Посмотреть сообщение
Strcmp is a good way aswell if you dont want to make a dynamic system but if I was you I would stick with strcmp if there is only 3 people that I want to make private if its more I wiuld stick with y_Ini and i cant post examples cause I am connected via my phone leave a msg on my pm and I will help sou tomorrow
Or just make a stock function using strfind in the playername? Example:

pawn Код:
stock findName(playerid)
    {
        new pname[MAX_PLAYER_NAME];
        else if(strfind(pname,"PUTNAMEHERE",true) != (-1)) return 0;
    }
Then you'd just write:
pawn Код:
if(findName(playerid)) // then wrap everything inside it then: else return SendClientMEssage(playerid, -1, "You dont have permission to use this");
inside of the function it'll do the same thing There are many ways of doing this, I prefer strfind than to strcmp, because strcmp compares different strings, strfind just finds it if you put a correct definitive on it
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)