/gotols /gotosf /gotolv -
Jaua10 - 05.06.2018
Excuse me guys im trying to made a admin cmd to teleport to ls sf and lv but only ls work i got this, what i made wrong?
PHP код:
CMD:gotols(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, NOTADMIN);
else
{
PlayerInfo[playerid][pInt] = 0;
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 1258.7352,-2036.7100,59.4561);
SendClientMessage(playerid, COLOR_WHITE, "You have been teleported to Los Santos!");
}
return 1;
}
CMD:gotosf(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, NOTADMIN);
else
{
PlayerInfo[playerid][pInt] = 0;
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, -2018.0339,145.6004,27.9839);
SendClientMessage(playerid, COLOR_WHITE, "You have been teleported to San Fierro!");
}
return 1;
}
CMD:gotolv(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, NOTADMIN);
else
{
PlayerInfo[playerid][pInt] = 0;
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 2034.0673,1007.7039,10.8203);
SendClientMessage(playerid, COLOR_WHITE, "You have been teleported to Las Venturas!");
}
return 1;
}
Re: /gotols /gotosf /gotolv -
mmostafa - 05.06.2018
You've made
PHP код:
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, NOTADMIN);
then else
You could make it with two ways the 1st is:
PHP код:
if(PlayerInfo[playerid][pAdmin] >= 2)
{
PlayerInfo[playerid][pInt] = 0;
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 1258.7352,-2036.7100,59.4561);
SendClientMessage(playerid, COLOR_WHITE, "You have been teleported to Los Santos!");
}
else
{
SendClientMessage(playerid, -1, NOTADMIN); //If NOTADMIN Is defined
}
return 1;
}
OR
PHP код:
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, NOTADMIN);
{ //without else
PlayerInfo[playerid][pInt] = 0;
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 1258.7352,-2036.7100,59.4561);
SendClientMessage(playerid, COLOR_WHITE, "You have been teleported to Los Santos!");
}
return 1;
}
Re: /gotols /gotosf /gotolv -
Sew_Sumi - 05.06.2018
If the code doesn't need params, then why are you actually accepting them?
Код:
CMD:gotols(playerid)
is all you need.
Код:
CMD:gotols(playerid)
{
if(!IsPlayerAdmin(playerid)) {return 0;}
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 1258.7352,-2036.7100,59.4561);
SendClientMessage(playerid, COLOR_WHITE, "You have been teleported to Los Santos!");
return 1;
}
CMD:gotosf(playerid)
{
if(!IsPlayerAdmin(playerid)) {return 0;}
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, -2018.0339,145.6004,27.9839);
SendClientMessage(playerid, COLOR_WHITE, "You have been teleported to San Fierro!");
return 1;
}
CMD:gotolv(playerid)
{
if(!IsPlayerAdmin(playerid)) {return 0;}
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 2034.0673,1007.7039,10.8203);
SendClientMessage(playerid, COLOR_WHITE, "You have been teleported to Las Venturas!");
return 1;
}
I just modified it to work on a stock script. You'd be better off following the example I have provided, than following the guy above.
Re: /gotols /gotosf /gotolv -
Jaua10 - 05.06.2018
doesnt work...maybe im doing something wrong, let me check it out
Re: /gotols /gotosf /gotolv -
Sew_Sumi - 05.06.2018
If anything does bug out, the best way to see if it actually works is to chuck it into a bare script, and see if you can get it going that way.
Then you're not dealing with variables and statements that will need checking.
You've got a lot of things in the command that aren't needed. Do as I do, and check the admin level then return the message, and DON'T put { }... There is no need to do so, and doing so, is just bad.
You can have single line if statements, especially when you are returning a message, or a return in the slightest.
You only use those braces when you are doing a structure, and with this, there is no reason to do a structure, as it's just one check, and if returned, it won't do the rest at all.