About SetPlayerDrunkLevel !
#1

Hello! This is my Command to set the Drunk Level.

It is not setting the Drunk Level, Can any one tell me why?
pawn Код:
CMD:drunk(playerid, params[])
{
    if(pInfo[playerid][pAdminLevel]> 1 ) return 0;
    if( GetPlayerVirtualWorld( playerid ) != 0 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] You can't use Admin Commands in Virtual World !" );
    new giveplayerid;
    new DrunkLevel;
    if(sscanf(params,"u",playerid)) return SendClientMessage(playerid, COLOR_RED1, "[ ! ] USAGE: /drunk <playerid> <drunklevel>");
    SetPlayerDrunkLevel(giveplayerid, DrunkLevel);
    if( DrunkLevel < 2000 || DrunkLevel > 50000 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] Invalid Drunk Level (2000-50000)." );
    SendClientMessage(giveplayerid, COLOR_RED1, "[ ! ] Your Drunk Level has been set to %d by an Admin");
    return 1;
}
Reply
#2

It's because you never specified DrunkLevel to take the value of a parameter.
So DrunkLevel was always 0.
pawn Код:
CMD:drunk(playerid, params[])
{
    if(pInfo[playerid][pAdminLevel] < 1 ) return 0;
    if( GetPlayerVirtualWorld( playerid ) != 0 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] You can't use Admin Commands in Virtual World !" );
    new giveplayerid,DrunkLevel;
    if(sscanf(params,"ui",giveplayerid,DrunkLevel)) return SendClientMessage(playerid, COLOR_RED1, "[ ! ] USAGE: /drunk <playerid> <drunklevel>");
    if( DrunkLevel < 2000 || DrunkLevel > 50000 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] Invalid Drunk Level (2000-50000)." );
    SetPlayerDrunkLevel(giveplayerid, DrunkLevel);
    SendClientMessage(giveplayerid, COLOR_RED1, "[ ! ] Your Drunk Level has been set to %d by an Admin");
    return 1;
}
EDIT: I fixed the command up a bit more. People with admin level of 2+ will not be able to use it. I made it so people with admin level of 0 will not be able to use it. Also;
pawn Код:
if( DrunkLevel < 2000 || DrunkLevel > 50000 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] Invalid Drunk Level (2000-50000)." );
Should be before:
pawn Код:
SetPlayerDrunkLevel(giveplayerid, DrunkLevel);

EDIT2: Also, you were storing the 'PlayerId/PartOfName' passed as a parameter into 'playerid' instead of 'giveplayerid'.
Reply
#3

Thanks Dear.

Can you tell me What is the difference Between params,"u" and params "ui" ?
Reply
#4

'u' specifier refers to player name/id. 'i' means integer value like amount of money, health, score, armour etc.
Reply
#5

Thanks. After Doing [pAdminLevel] < 1 from [pAdminLevel] > 1, Now My Admin level is "0" and I am not able to use any Commands OMG, Fix that Problem please?

I was using this.

pawn Код:
[pAdminLevel] > 1
then I was Able to use Commands. Now EiresJasOn told me to do that:

pawn Код:
[pAdminLevel] < 1
And After doing /admins, It is showing my Admin Level 0 and I can't use COmmands now...
Reply
#6

Set your [pAdminLevel] to 1 then?

Your code was allowing non-administrators to use the command.

If you cannot use the command after the code i gave you, it means you need to make yourself atleast a level 1 administator.
Reply
#7

How can I make myself dude? I even can't use /nominate command (I am not Admin).
Reply
#8

Post me your /nominate code below.

Also; you could also go into your scriptfiles and change it that way.
Reply
#9

pawn Код:
CMD:nominate(playerid, params[])
{
 if(GetPlayerVirtualWorld(playerid)==1) return SendClientMessage (playerid, COLOR_RED, "[ ! ] You cannot use Admin Commands in Event world !" );
 if(pInfo[playerid][pAdminLevel] < 2 ) return 0;
 if( GetPlayerVirtualWorld( playerid ) != 0 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] You can't use Admin Commands in Virtual World !" );
 new targetid, level;
 if( sscanf( params, "ui", targetid, level ) ) return SendClientMessage( playerid, COLOR_RED1, "[ ! ] USAGE: /nominate <player> <level>" ); // this use "ui" not
 if( targetid==INVALID_PLAYER_ID ) return SendClientMessage( playerid, COLOR_RED, "[ ! ] Invalid Player ID !" );
 if( level<0 ) return SendClientMessage( playerid, COLOR_RED, "[ ! ]  Invalid Admin level !" );
 if( pInfo[playerid][pAdminLevel]<=pInfo[targetid][pAdminLevel] ) return SendClientMessage( playerid, COLOR_YELLOW, "[ ! ] ERROR: You can't nominate this player !" );
 if( pInfo[playerid][pAdminLevel]<=level ) return SendClientMessage( playerid, COLOR_RED, "[ A ] ERROR: You can't use this level !" );
 pInfo[targetid][pAdminLevel] = level;
 new sMessage[128],PlayerName[24],OtherName[24];
 GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
 GetPlayerName(targetid,OtherName,sizeof(OtherName));
 format( sMessage, sizeof(sMessage), "[ ! ] You have nominated %s as admin level %d !", OtherName, level );
 SendClientMessage( playerid, COLOR_GREEN, sMessage );
 format( sMessage, sizeof(sMessage), "[ A ] You have been nominated admin level %d by %s !", level, PlayerName);
 SendClientMessage( targetid, COLOR_GREEN, sMessage );
 SendClientMessage( targetid, COLOR_WHITE, "[ ! ] Type /acmd to see Admin Commands" );
 return 1;
}
Reply
#10

Do you save the player's administrator level to his user file?

Also, why do have this line?
pawn Код:
if( pInfo[playerid][pAdminLevel]<=level ) return SendClientMessage( playerid, COLOR_RED, "[ A ] ERROR: You can't use this level !" );
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)