Need help on two things.
#1

I have this code that sends the player to a punishment house far out to sea and I want to make it so when the player gets teleported his admin level gets demoted to 0 and he cannot use commands.

Here is what I have so far.

I have this defined at the top of my filterscript.

pawn Код:
#define dcmd(%1,%2,%3) if(!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
I then have this under OnPlayerCommandText.

pawn Код:
dcmd(housepun,8,cmdtext);
I then have this at the very bottom of my script.

pawn Код:
dcmd_housepun(playerid,params[])
{
    if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,COLOR_RED,"ERROR: You are not a high enough level to use this command");
    if(!strlen(params)) return SendClientMessage(playerid, COLOR_PINK, "USAGE: /housepun [playerid]");
    new player1 = strval(params), string[128], pName[24];
    if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
    {
        GetPlayerName(playerid, pName, 24);

        format(string, sizeof(string), "You have punished \"%s\" ", pName);
        SendClientMessage(playerid,COLOR_PINK,string);
        if(player1 != playerid)
        {
            format(string,sizeof(string),"Administrator \"%s\" has punished you", pName);
            SendClientMessage(player1,COLOR_PINK,string);
        }
        SetPlayerPos(player1, 694.7562,-2377.2427,-0.0825);
    }
    if(!IsPlayerConnected(player1) || player1 == INVALID_PLAYER_ID ) return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is not connected");
    return 1;
}
This works perfectly, it teleports the player to were I want them to go and it gives them the client message. But I want it to make the player that IS getting teleported to the housepun (my punishment) to get demoted to admin level 0 and not been able to use commands.

I am using Ladmin for my admin script.

Thanks.
Reply
#2

I dont know much about dcmd,

i could do it if i had the script but right now i cant.
Reply
#3

K in your code add this:

PHP код:
dcmd_housepun(playerid,params[])
{
    if(!
IsPlayerAdmin(playerid))return SendClientMessage(playerid,COLOR_RED,"ERROR: You are not a high enough level to use this command");
    if(!
strlen(params)) return SendClientMessage(playeridCOLOR_PINK"USAGE: /housepun [playerid]");
    new 
player1 strval(params), string[128], pName[24];
    if(
IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
    {
        
GetPlayerName(playeridpName24);
        
format(stringsizeof(string), "You have punished \"%s\" "pName);
        
SendClientMessage(playerid,COLOR_PINK,string);
        if(
player1 != playerid)
        {
            
format(string,sizeof(string),"Administrator \"%s\" has punished you"pName);
            
SendClientMessage(player1,COLOR_PINK,string);
        }
        
SetPlayerPos(player1694.7562,-2377.2427,-0.0825);
        
SetPVarInt(player1"housepun"1); // Set a pvar
    
}
    if(!
IsPlayerConnected(player1) || player1 == INVALID_PLAYER_ID ) return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is not connected");
    return 
1;

Then:

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    
//MUST BE AT THE TOP!!
    
if(GetPVarInt(playerid"housepun")) return SendClientMessage(playerid0xFFFFFF"You have been punished and cannot use commands or teleports");

NOTE: If you are using multiple filterscripts, its important you add that line in all the filterscripts, otherwise the player can still use commands.

To undo this you could make a command similar to this:

PHP код:
dcmd_unhousepun(playeridparams[])
{
    new 
player1;
    if(
sscanf(params"u"player1)) return SendClientMessage(playerid0xFFFFFF"USAGE: /unhousepun [id]");
    if(!
GetPVarInt(player1"housepun")) return SendClientMessage(playerid0xFFFFFF"ERROR: This player is currently not punished");
    
DeletePVar(player1"housepun");
    
SendClientMessage(player10xFFFFFF"You are not longer punished");
    
SendClientMessage(playerid0xFFFFFF"Player is not punished anymore");
    return 
1;

Reply
#4

pawn Код:
dcmd_housepun(playerid,params[])
{
    if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,COLOR_RED,"ERROR: You are not a high enough level to use this command");
    if(!strlen(params)) return SendClientMessage(playerid, COLOR_PINK, "USAGE: /housepun [playerid]");
    new player1 = strval(params), string[128], pName[24];
    if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
    {
        GetPlayerName(player1, pName, 24);

        format(string, sizeof(string), "You have punished \"%s\" ", pName);
        SendClientMessage(playerid,COLOR_PINK,string);
        if(player1 != playerid)
        {
            format(string,sizeof(string),"Administrator \"%s\" has punished you", pName);
            SendClientMessage(player1,COLOR_PINK,string);
        }
        SetPlayerPos(player1, 694.7562,-2377.2427,-0.0825);
    }
    if(!IsPlayerConnected(player1) || player1 == INVALID_PLAYER_ID ) return SendClientMessage(playerid,COLOR_RED,"ERROR: Player is not connected");
    return 1;
}
for the admin level just add the definition for levels from ladmin (which I don't know)..
e.g. PlayerInfo[player1][Level] = 0;

edit: hm someone before me lol
Reply
#5

Thank you Sinner.

and @Sascha do you mean like this?
pawn Код:
if(PlayerInfo[I][Level] > 0)
Reply
#6

Sorry for the bump but I need this.
Reply
#7

Why not make a variable?

pawn Код:
// top of script

new InHousePun[MAX_PLAYERS];

// Under OnPlayerConnect, OnPlayerRequestClass, OnPlayerDisconnect, OnPlayerSpawn

InHousePun[playerid] = 0;

// in your command

InHousePun[player1] = 1;

if(InHousePun[player1] == 1)
{
      PlayerInfo[playerid][Level] == 0 // player1's admin level will be set to 0
      SendClientMessage(player1,COLOR_PINK,"You Have Been Demoted To Level 0.");
}
You can also use that if statement in other commands too, just change a couple things. I am not 100%
sure it will work but give it a try. I also use LAdmin.
Reply
#8

I am not sure if this is correct but my command now looks like this.

pawn Код:
dcmd_housepun(playerid,params[])
{
    if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid,COLOR_LIGHTRED,"ERROR: You are not a high enough level to use this command");
    if(!strlen(params)) return SendClientMessage(playerid, COLOR_PINK, "USAGE: /housepun [playerid]");
    new player1 = strval(params), string[128], pName[24];
    if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
    {
        GetPlayerName(playerid, pName, 24);

        format(string, sizeof(string), "You have punished \"%s\" ", pName);
        SendClientMessage(playerid,COLOR_PINK,string);
        if(player1 != playerid)
        {
            format(string,sizeof(string),"Administrator \"%s\" has punished you", pName);
            SendClientMessage(player1,COLOR_PINK,string);
        }
        SetPlayerPos(player1, 694.7562,-2377.2427,-0.0825);
        SetPVarInt(player1, "housepun", 1); // Set a pvar
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid, 14, 0);
    }
    InHousePun[player1] = 1;
   
    if(InHousePun[player1] == 1)
    {
          PlayerInfo[playerid][Level] == 0 // player1's admin level will be set to 0
          SendClientMessage(player1,COLOR_PINK,"You Have Been Demoted To Level 0.");
    }
    if(!IsPlayerConnected(player1) || player1 == INVALID_PLAYER_ID ) return SendClientMessage(playerid,COLOR_LIGHTRED,"ERROR: Player is not connected");
    return 1;
}
and I get the following errors.

Код:
C:\Users\J\Desktop\sa-mp files\filterscripts\SA.pwn(3204) : error 017: undefined symbol "PlayerInfo"
C:\Users\J\Desktop\sa-mp files\filterscripts\SA.pwn(3204) : warning 215: expression has no effect
C:\Users\J\Desktop\sa-mp files\filterscripts\SA.pwn(3204) : error 001: expected token: ";", but found "]"
C:\Users\J\Desktop\sa-mp files\filterscripts\SA.pwn(3204) : error 029: invalid expression, assumed zero
C:\Users\J\Desktop\sa-mp files\filterscripts\SA.pwn(3204) : fatal error 107: too many error messages on one line
Line 3204.
pawn Код:
PlayerInfo[playerid][Level] == 0 // player1's admin level will be set to 0
Also on this bit here.
pawn Код:
SetPlayerPos(player1, 694.7562,-2377.2427,-0.0825);
        SetPVarInt(player1, "housepun", 1); // Set a pvar
        ResetPlayerWeapons(playerid);
        GivePlayerWeapon(playerid, 14, 0);
on ResetPlayerWeapons and GivePlayerWeapons, it does that to the person typing the command, not the the person who is getting punished.

Thanks.


Edit: In this script I don't have OnPlayerRequestClass, I only have that in the gamemode, this is just a filterscript.
Reply
#9

Ah sorry, for line 3204, add a ; at the end of it and tell me if it works.

And for that little snippet, for ResetPlayerWeapon and GivePlayerWeapon, it should be player1, not playerid (player1 is the person being punished, while playerid is the id of the admin)

The SetPlayerPos and SetPVarInt are correct with "player1".
Reply
#10

I have added a ; on the end so it now looks like this.

pawn Код:
PlayerInfo[playerid][Level] == 0; // player1's admin level will be set to 0
and I still get these errors.

Код:
C:\Users\J\Desktop\sa-mp files\filterscripts\SA.pwn(3204) : error 017: undefined symbol "PlayerInfo"
C:\Users\J\Desktop\sa-mp files\filterscripts\SA.pwn(3204) : warning 215: expression has no effect
C:\Users\J\Desktop\sa-mp files\filterscripts\SA.pwn(3204) : error 001: expected token: ";", but found "]"
C:\Users\J\Desktop\sa-mp files\filterscripts\SA.pwn(3204) : error 029: invalid expression, assumed zero
C:\Users\J\Desktop\sa-mp files\filterscripts\SA.pwn(3204) : fatal error 107: too many error messages on one line
and thanks, I totally forgot about Player1.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)