Problem
#1

Hey guys, I got a problem.
Like i want to do: (example)
pawn Код:
dcmd_agoto(playerid,params[])
{
    new id,Float:x,Float:y,Float:z,string[128];
    CheckLvl(playerid,3);
    if(sscanf(params,"u",id)) return SHM(playerid,"/agoto <playerid / name>","Will teleport yourself to the player specified!");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,red,notconnected);
    GetPlayerPos(id,x,y,z);
    SetPlayerInterior(playerid,GetPlayerInterior(id));
    if(!IsPlayerInAnyVehicle(playerid))
    {
        SetPlayerPos(playerid,x+2,y,z);
    }
    else
    {
        SetVehiclePos(GetPlayerVehicleID(playerid),x+2,y,z);
        PutPlayerInVehicle(playerid,GetPlayerVehicleID(playerid),0);
    }
    format(string,sizeof(string),"» You have successfully teleported to "lyellow2"%s(ID:%d)"lgreen2"!",GetPName(id),id);
    SendClientMessage(playerid,green2,string);
    return 1;
}
That CheckLvl(playerid,3); is if his level is < 3 then return a message, i have on this public.
But even if he's level 0, it still lets him use it. Why?
pawn Код:
forward CheckLvl(playerid,levelo);
public CheckLvl(playerid,levelo)
{
    new string[165];
    format(string,sizeof(string),"ERROR: You need level "lorange"%i"lwhite" to use this command!",levelo);
    if(PInfo[playerid][Level] < levelo) return SendClientMessage(playerid,white,string);
    return 0;
}
Reply
#2

Hello!

You have to check it with an if statement and let the function return a specific value:

pawn Код:
dcmd_agoto(playerid,params[])
{
    new id,Float:x,Float:y,Float:z,string[128];
    if(CheckLvl(playerid,3) == -9999) //If the function does return -9999, they player has the correct level.
    {
        if(sscanf(params,"u",id)) return SHM(playerid,"/agoto <playerid / name>","Will teleport yourself to the player specified!");
        if(!IsPlayerConnected(id)) return SendClientMessage(playerid,red,notconnected);
        GetPlayerPos(id,x,y,z);
        SetPlayerInterior(playerid,GetPlayerInterior(id));
        if(!IsPlayerInAnyVehicle(playerid))
        {
            SetPlayerPos(playerid,x+2,y,z);
        }
        else
        {
            SetVehiclePos(GetPlayerVehicleID(playerid),x+2,y,z);
            PutPlayerInVehicle(playerid,GetPlayerVehicleID(playerid),0);
        }
        format(string,sizeof(string),"» You have successfully teleported to "lyellow2"%s(ID:%d)"lgreen2"!",GetPName(id),id);
        SendClientMessage(playerid,green2,string);
    }
    return 1;
}
Function:

pawn Код:
forward CheckLvl(playerid,levelo);
public CheckLvl(playerid,levelo)
{
    if(PInfo[playerid][Level] >= levelo) return -9999;
    new string[165];
    format(string,sizeof(string),"ERROR: You need level "lorange"%i"lwhite" to use this command!",levelo);
    return SendClientMessage(playerid,white,string);
}
I hope this helps you.

Jeffry
Reply
#3

Thank you, but I don't think you understood me at all.
I want when I do this
pawn Код:
CheckLvl(playerid,level);
it automatically to check if the player has the right level to perform the command, and if not, send him a message saying what level he needs.
Reply
#4

Try the command, it should do it as you want it.

Jeffry
Reply
#5

Oh yeah, you are right, sorry.
Thanks again
Reply
#6

Quote:
Originally Posted by Delux13
Посмотреть сообщение
Oh yeah, you are right, sorry.
Thanks again
No problem. Have fun.
Thank you for the Reputation Point.

Jeffry
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)