SA-MP Forums Archive
Need help on two things. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need help on two things. (/showthread.php?tid=250730)



Need help on two things. - captainjohn - 24.04.2011

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.


Re: Need help on two things. - dannyk0ed - 24.04.2011

I dont know much about dcmd,

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


Re: Need help on two things. - Sinner - 24.04.2011

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;




Re: Need help on two things. - Sascha - 24.04.2011

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


Re: Need help on two things. - captainjohn - 24.04.2011

Thank you Sinner.

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



Re: Need help on two things. - captainjohn - 24.04.2011

Sorry for the bump but I need this.


Re: Need help on two things. - grand.Theft.Otto - 24.04.2011

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.


Re: Need help on two things. - captainjohn - 24.04.2011

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.


Re: Need help on two things. - grand.Theft.Otto - 24.04.2011

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


Re: Need help on two things. - captainjohn - 24.04.2011

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.