/gotols /gotosf /gotolv
#1

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(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playeridCOLOR_REDNOTADMIN);
    else
    {
        
PlayerInfo[playerid][pInt] = 0;
        
SetPlayerInterior(playerid0);
           
SetPlayerPos(playerid1258.7352,-2036.7100,59.4561);
           
SendClientMessage(playeridCOLOR_WHITE"You have been teleported to Los Santos!");
    }
    return 
1;
}
CMD:gotosf(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playeridCOLOR_REDNOTADMIN);
    else
    {
        
PlayerInfo[playerid][pInt] = 0;
        
SetPlayerInterior(playerid0);
           
SetPlayerPos(playerid, -2018.0339,145.6004,27.9839);
           
SendClientMessage(playeridCOLOR_WHITE"You have been teleported to San Fierro!");
    }
    return 
1;
}
CMD:gotolv(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playeridCOLOR_REDNOTADMIN);
    else
    {
        
PlayerInfo[playerid][pInt] = 0;
        
SetPlayerInterior(playerid0);
           
SetPlayerPos(playerid2034.0673,1007.7039,10.8203);
           
SendClientMessage(playeridCOLOR_WHITE"You have been teleported to Las Venturas!");
    }
    return 
1;

Reply
#2

You've made
PHP код:
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playeridCOLOR_REDNOTADMIN); 
then else
You could make it with two ways the 1st is:
PHP код:
 if(PlayerInfo[playerid][pAdmin] >= 2
          {
                 
PlayerInfo[playerid][pInt] = 0
                 
SetPlayerInterior(playerid0); 
                 
SetPlayerPos(playerid1258.7352,-2036.7100,59.4561); 
                 
SendClientMessage(playeridCOLOR_WHITE"You have been teleported to Los Santos!"); 
           }
            else
               {
                           
SendClientMessage(playerid, -1NOTADMIN); //If NOTADMIN Is defined
                
}
                return 
1;

OR
PHP код:
 if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playeridCOLOR_REDNOTADMIN); 
    { 
//without else
        
PlayerInfo[playerid][pInt] = 0
        
SetPlayerInterior(playerid0); 
           
SetPlayerPos(playerid1258.7352,-2036.7100,59.4561); 
           
SendClientMessage(playeridCOLOR_WHITE"You have been teleported to Los Santos!"); 
    } 
    return 
1

Reply
#3

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.
Reply
#4

doesnt work...maybe im doing something wrong, let me check it out
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)