SA-MP Forums Archive
help please! - 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)
+--- Thread: help please! (/showthread.php?tid=555454)



help please! - aCloudy - 07.01.2015

When i compile this, I get that error, "/setvip 5" 5 = s_vip

Code:
if(IsVIP[ID] == 0 && s_vip == 0)
	{
	    format(string,sizeof(string),"{AFAFAF}[Error]: {FFFFFF}This player is not VIP.");
	    SendClientMessage(playerid,COLOR_WHITE,string);
	    return 1;
	}
C:\Program Files\lvcnrr\gamemodes\LVCNR1.pwn(18714) : error 033: array must be indexed (variable "s_vip")
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.


Re: help please! - Divergent - 07.01.2015

We need more information. Show us where you defined/initilialized s_vip.


Re: help please! - aCloudy - 07.01.2015

Quote:
Originally Posted by Divergent
View Post
We need more information. Show us where you defined/initilialized s_vip.
Code:
dcmd_setvip(playerid,params[])
{
	new ID;
	new vip;
	new s_vip[100];
	new string[128];
	if(!IsPlayerName(playerid,"TheOwner") && !IsPlayerName(playerid, "TheOwner2")) return SCM(playerid,COLOR_WHITE,"{FF0000}[ERROR]{FFFFFF}You have submitted an invalid command, Type /commands or /cmds to see the server commands");
    if(sscanf(params,"ui",ID,vip))
	{
	    SendClientMessage(playerid,COLOR_WHITE,""COL_USAGE"[SYNTAX] {FFFFFF}/setvip [PLAYER_ID] [VIP_LEVEL]");
	    return 1;
	}
	if(!IsPlayerConnected(ID))
	{
	    format(string,sizeof(string),"{AFAFAF}[Error]: {FFFFFF}Invalid player ID.");
	    SendClientMessage(playerid,COLOR_WHITE,string);
	    return 1;
	}
	if(IsVIP[ID] == 0 && s_vip == 0)
	{
	    format(string,sizeof(string),"{AFAFAF}[Error]: {FFFFFF}This player is not VIP.");
	    SendClientMessage(playerid,COLOR_WHITE,string);
	    return 1;
	}
	IsVIP[ID] =vip;

	if(IsVIP[ID] == 0)
	{ format(s_vip,sizeof(s_vip),"{FFFFFF}N/A"); }
	if(IsVIP[ID] == 1)
	{ format(s_vip,sizeof(s_vip),"{006600}Regular"); }
 	if(IsVIP[ID] == 2)
	{ format(s_vip,sizeof(s_vip),"{660000}Alpha"); }
	if(IsVIP[ID] == 3)
	{ format(s_vip,sizeof(s_vip),"{AFAFAF}Royal"); }
	if(IsVIP[ID] == 4)
	{ format(s_vip,sizeof(s_vip),"{FFFF00}Elite"); }
	if(IsVIP[ID] == 5)
	{ format(s_vip,sizeof(s_vip),"{6600FF}Delta"); }

	format(string,sizeof(string),""COL_ADMIN"[ADMIN] {FFFFFF}%s has set your V.I.P level to {F8E607}%s{FFFFFF}!",PlayerName(playerid),s_vip);
	SendClientMessage(ID,COLOR_WHITE,string);
	format(string,sizeof(string),""COL_ADMIN"[ADMIN] {FFFFFF}You have set {AFAFAF}%s(%d){FFFFFF}'s V.I.P level to {F8E607}%s{FFFFFF}!",PlayerName(ID),ID,s_vip);
	SendClientMessage(playerid,COLOR_WHITE,string);
	return 1;
}



Re: help please! - Divergent - 07.01.2015

Code:
new s_vip[100];
s_vip is created inside of a command, which makes it a local variable (only exists inside of that command). You need to create it globally (outside of any commands or functions) so that it can be used anywhere. Rep+ man and PM me if you need any more help.


Re: help please! - aCloudy - 07.01.2015

Quote:
Originally Posted by Divergent
View Post
Code:
new s_vip[100];
s_vip is created inside of a command, which makes it a local variable (only exists inside of that command). You need to create it globally (outside of any commands or functions) so that it can be used anywhere. Rep+ man and PM me if you need any more help.
Pasted new s_vip[100]; out the command and removed it from the command.
But same error:


C:\Program Files\lvcnrr\gamemodes\LVCNR1.pwn(17226) : warning 219: local variable "s_vip" shadows a variable at a preceding level
C:\Program Files\lvcnrr\gamemodes\LVCNR1.pwn(18714) : error 033: array must be indexed (variable "s_vip")
C:\Program Files\lvcnrr\gamemodes\LVCNR1.pwn(18761) : warning 219: local variable "s_vip" shadows a variable at a preceding level
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.


Re: help please! - Divergent - 07.01.2015

You're creating the s_vip variable multiple times (probably once globally and other times in commands). Check your script and remove the repetitive "new s_vip"