SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/01/2018, 08:57 PM   #1
FrenkMartin
Little Clucker
 
Join Date: Sep 2016
Posts: 2
Reputation: 0
Question Problem with player variable

Hello there,
( i am a beginner in this )
Sorry if i mistake at forum thread or something...
i have one problem in my script. I make a command to punish someone with jail and similar things. I did it in way where an administrator must revise her parameters. Here is a code:
Code:
CMD:kazniigraca( playerid, params[] ) {
    if( PlayerInfo[ playerid ][ xAdmin ] >= 1  ) {
    
        if( !AdminDuty[ playerid ] ) return GRESKA( playerid, "Da bi koristili ovu komandu morate biti Admin na duznosti" );
		new id,reason,string[200];
		if( sscanf(params, "ui", id, reason ) ) {
		
			SendUsageMessage( playerid, "/kazniigraca [ ID/Deo imena ] [ Broj razloga ]");
			SendUsageMessage( playerid, "1 DM | 2 SK | 3 RK | 4 PG | 5 MG | 6 DB | 7 NJ | 8 PvP" );
			SendUsageMessage( playerid, "9 KOS | 10 TK | 11 Vredjanje | 12 Ometanje Radnika" );
			SendUsageMessage( playerid, "13 Prevara | 14 Invalid /ad | 15 CR | 16 PvE" );
			return 1;
		}
		if( id == IPI ) return GRESKA( playerid, "Uneli ste pogresan ID igraca." );
		if(reason > 1 && reason < 16) // type of punishment
		{
         new kazna[35];
		 Idkazne[playerid] = reason; // this is variable to save a number of punishment for proceeding agreement
		 Idkaznenog[playerid] = id; // save a ID of player who is punish by administrator
		 switch(reason) {
		 case 1: kazna = "DeathMatch(DM)";
		 case 2: kazna = "SpawnKill(SK)";
		 case 3: kazna = "RevengeKill(RK)";
		 case 4: kazna = "PowerGaming(PG)";
		 case 5: kazna = "MetaGaming(MG)";
		 case 6: kazna = "Drive-by(DB)";
		 case 7: kazna = "NinjaJacking";
		 case 8: kazna = "PlayerVsPlayer(PvP)";
		 case 9: kazna = "KillOnSight(KOS)";
		 case 10: kazna = "TeamKill(TK)";
		 case 11: kazna = "Vredjanje";
		 case 12: kazna = "Ometanje Radnika";
		 case 13: kazna = "Prevara";
		 case 14: kazna = "Invalid advertise";
		 case 15: kazna = "ChickenRun(CK)";
		 case 16: kazna = "PlayerVsEnviroment(PvE)";
		 }
		 format(string,sizeof(string),"(CHECK)\n\nDa li želite da izvršite radnju sa navedenim paramterima?\n\nIgrac: %s (%d)\nKazna: %s (Broj: %d)\n\n(CHECK)",ImeIgraca(playerid),playerid,kazna,reason);
		 SPD(playerid,dialog_PROVERAKAZNE,DIALOG_STYLE_MSGBOX,""col_sanm"PROVJERA KAZNE",string,"Da","Ne");
		 return 1;
		}
		else
		{
             GRESKA(playerid,"Doslo je do greške ponovite radnju!");
        }
    }
	else return GRESKA( playerid, "Niste u mogucnosti koristiti ovu komandu." );
	return 1;
}
But when i response this dialog nothing happend, i don't know where is problem. If you can help me, i will rep it. Thanks forward.
Here is a response of dialog: (( don't look at size of code, that is not so important, look at // commented parts. ))
Code:
else if( dialogid == dialog_PROVERAKAZNE)
	{
	  if(!response) { Idkazne[playerid] = -1; Idkaznenog[playerid] = -1; SendInfoMessage(playerid,"Odustali ste od kazne."); }
	  if(response)
	  {
		new reason, id;
		Idkazne[playerid] = reason; // this is place where i use a variable of player( number of punishment)
		Idkaznenog[playerid] = id; // number of punishmented player
		if( reason == 1 ) {

		    JailPlayer( id, 60 );
		    DajIgracuNovac( id, -5000 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"DM." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"60 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"5000$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: DM.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 2 ) {

		    JailPlayer( id, 30 );
		    DajIgracuNovac( id, -2500 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"SK." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"30 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"2500$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: SK.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 3 ) {

		    JailPlayer( id, 30 );
		    DajIgracuNovac( id, -2500 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"RK." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"30 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"2500$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: RK.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 4 ) {

		    JailPlayer( id, 30 );
		    DajIgracuNovac( id, -3000 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"PG." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"30 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"3000$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: PG.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 5 ) {

		    JailPlayer( id, 10 );
		    DajIgracuNovac( id, -500 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"MG." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"10 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"500$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: MG.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 6 ) {

		    JailPlayer( id, 45 );
		    DajIgracuNovac( id, -3500 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"DB." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"45 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"3500$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: DB.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 7 ) {

		    JailPlayer( id, 30 );
		    DajIgracuNovac( id, -2500 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"NJ." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"30 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"2500$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: NJ.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 8 ) {

		    JailPlayer( id, 30 );
		    DajIgracuNovac( id, -2500 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"PvP." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"30 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"2500$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: PvP.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 9 ) {

		    JailPlayer( id, 30 );
		    DajIgracuNovac( id, -2500 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"KOS." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"30 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"2500$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: KOS.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 10 ) {

		    JailPlayer( id, 45 );
		    DajIgracuNovac( id, -3000 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"TK." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"45 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"3000$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: TK.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 11 ) {

		    JailPlayer( id, 60 );
		    DajIgracuNovac( id, -5000 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"Vredjanje." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"60 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"5000$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: Vredjanje.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 12 ) {

		    JailPlayer( id, 45 );
		    DajIgracuNovac( id, -3000 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"Ometanje radnika." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"45 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"3000$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: Ometanje radnika.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 13 ) {

		    JailPlayer( id, 600 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"Prevara." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"600 minuta." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: Prevara.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 14 ) {

		    JailPlayer( id, 15 );
		    DajIgracuNovac( id, -500 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"Invalid /ad." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"15 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"500$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: Invalid /ad.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 15 ) {

		    JailPlayer( id, 30 );
		    DajIgracuNovac( id, -2000 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"CR." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"30 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"2000$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: CR.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		  Idkaznenog[playerid] = -1;
		}
		else if( reason == 16 ) {

		    JailPlayer( id, 30 );
		    DajIgracuNovac( id, -2000 );

		    SendClientMessage( id, ANTICHEAT, "________________________________________");
		    SendClientMessageEx( id, -1, ""col_white"Admin vas je kaznio." );
		    SendClientMessageEx( id, -1, ""col_white"Razlog kazne: "col_extreme"PvE." );
		    SendClientMessageEx( id, -1, ""col_white"Dobili ste zatvor od "col_extreme"30 minuta." );
		    SendClientMessageEx( id, -1, ""col_white"Oduzeto vam je "col_extreme"2000$." );
		    SendClientMessage( id, ANTICHEAT, "________________________________________");

		    format( globalstring, sizeof( globalstring ), "KAZNA | Admin je kaznio igraca %s. Razlog: PvE.", ImeIgraca( id ) );
			SCMA( NARACRVENA, globalstring );
			Idkazne[playerid] = -1;
		    Idkaznenog[playerid] = -1;
		}
	  }
	}
FrenkMartin is offline   Reply With Quote
Old 09/01/2018, 09:06 PM   #2
skuller12
Big Clucker
 
Join Date: Feb 2015
Location: Galati, Romania
Posts: 101
Reputation: 0
Default Re: Problem with player variable

reason = Idkazne[playerid]
id = Idkaznenog[playerid]
skuller12 is offline   Reply With Quote
Old 09/01/2018, 09:12 PM   #3
Lucases
Huge Clucker
 
Join Date: Jul 2017
Posts: 216
Reputation: 11
Default Re: Problem with player variable

pawn Code:
new reason = Idkazne[playerid], id = Idkaznenog[playerid];

Replace that line and remove the two lines below
Lucases is offline   Reply With Quote
Old 09/01/2018, 10:14 PM   #4
FrenkMartin
Little Clucker
 
Join Date: Sep 2016
Posts: 2
Reputation: 0
Default Re: Problem with player variable

Thank for both of you I solve it
FrenkMartin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem - local variable "str" shadows a variable at a preceding level prooftzm Scripting Help 5 03/07/2014 09:38 PM
Dynamic Variable Naming / Variable Variables / Indirect Variable Access Redgie Scripting Help 3 04/06/2012 07:32 PM
player variable in array problem... knackworst Scripting Help 9 15/10/2011 01:23 PM
TextDraws as server variable?? How to i change to Player Variable? DarrenReeder Help Archive 2 06/04/2010 07:02 AM
Strange variable/player file problem Byrner Help Archive 8 24/05/2009 11:25 PM


All times are GMT. The time now is 12:56 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.