teleport commands for players names? -
kaos999 - 15.08.2013
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
Re : teleport commands for players names? -
Naruto_Emilio - 15.08.2013
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
Re: Re : teleport commands for players names? -
kaos999 - 15.08.2013
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
Re: teleport commands for players names? -
Lyksus - 15.08.2013
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.
Re: Re : teleport commands for players names? -
Lyksus - 15.08.2013
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
Re: teleport commands for players names? -
Legend_Of_War - 15.08.2013
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
Re: teleport commands for players names? -
Naruto_Emilio - 15.08.2013
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
Re: teleport commands for players names? -
Lyksus - 15.08.2013
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