SA-MP Forums Archive
ZCMD Help - 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: ZCMD Help (/showthread.php?tid=639958)



ZCMD Help - Miguelch1312 - 26.08.2017

Hi,
I converted some commands from STRCMP to ZMCD, but adding the commands to the gm drops warnings, and i wanna know why this is happening.
PD: I'm putting the commands at the end of the gamemode
The warnings:

"GM.pwn(3080) : warning 219: local variable "msg" shadows a variable at a preceding level"
"GM.pwn(4684) : warning 219: local variable "msg" shadows a variable at a preceding level"


Here's the line 4684:
PHP код:
CMD:claimcoupon(playeridparams[])
{
    new 
title[64], msg[126];//Line 4684
    
format(title,sizeof(title),"{1B8AE4}Claim Coupon");
    
format(msg,sizeof(msg),"Type the coupon code below to\nclaim your reward:");
    
ShowPlayerDialog(playeridcoupon1DIALOG_STYLE_INPUTtitlemsg"Claim""Cancel");
    return 
1;

Here's the line 3080:
PHP код:
public HouseEnter(playeridhouseid)
{
    if(
PInfo[playerid][House1] == HInfo[houseid][hHouseID]) { new msg[64]; format(msg,sizeof(msg),"Welcome   %s."PlayerName(playerid)); SendClientMessage(playeridCOLOR_WHITEmsg); }//Line 3080
    
if(PInfo[playerid][House2] == HInfo[houseid][hHouseID]) { new msg[64]; format(msg,sizeof(msg),"Welcome home, %s."PlayerName(playerid)); SendClientMessage(playeridCOLOR_WHITEmsg); }
    
InHouse[playerid] = houseid;
    
SetPlayerInterior(playeridHInfo[houseid][hInterior]);
    
SetPlayerPos(playeridHInfo[houseid][hiX],HInfo[houseid][hiY],HInfo[houseid][hiZ]);
    
SetPlayerVirtualWorld(playeridhouseid);
    return 
1;




Re: ZCMD Help - HoussemGaming - 26.08.2017

Check if you have a variable called 'msg' in an include


Respuesta: Re: ZCMD Help - Miguelch1312 - 26.08.2017

Quote:
Originally Posted by HoussemGaming
Посмотреть сообщение
Check if you have a variable called 'msg' in an include
I forgot to say that when i delete the "new msg[]" this appears, GM.pwn(4686) : error 017: undefined symbol "msg".

I'm checking the includes and if you need to know what are the includes:
#include <a_samp>
#include <a_mysql>
#include <streamer>
#include <sscanf2>
#include <utils>
#include <zcmd>

PD: I've checked the includes but anyone has msg defined, and i've more "new msg[]" but if i delete the ZCMD commands the warnings doesn't appear anymore


Respuesta: ZCMD Help - Miguelch1312 - 26.08.2017

Help plox


Re: ZCMD Help - FuNkYTheGreat - 26.08.2017

Код:
CMD:claimcoupon(playerid, params[])
{
    new title[64], msg2[126];//Line 4684
    format(title,sizeof(title),"{1B8AE4}Claim Coupon");
    format(msg2,sizeof(msg2),"Type the coupon code below to\nclaim your reward:");
    ShowPlayerDialog(playerid, coupon1, DIALOG_STYLE_INPUT, title, msg2, "Claim", "Cancel");
    return 1;
}
public HouseEnter(playerid, houseid)
{
    if(PInfo[playerid][House1] == HInfo[houseid][hHouseID]) { new msg2[64]; format(msg2,sizeof(msg2),"Welcome   %s.", PlayerName(playerid)); SendClientMessage(playerid, COLOR_WHITE, msg2); }//Line 3080
    if(PInfo[playerid][House2] == HInfo[houseid][hHouseID]) { new msg2[64]; format(msg2,sizeof(msg2),"Welcome home, %s.", PlayerName(playerid)); SendClientMessage(playerid, COLOR_WHITE, msg2); }
    InHouse[playerid] = houseid;
    SetPlayerInterior(playerid, HInfo[houseid][hInterior]);
    SetPlayerPos(playerid, HInfo[houseid][hiX],HInfo[houseid][hiY],HInfo[houseid][hiZ]);
    SetPlayerVirtualWorld(playerid, houseid);
    return 1;
}
In your script somewhere msg variable was already in use and it was a global variable , So it was conflicting with your those msg variable,
I change your msg variable to msg2, Now it'll works fine.


Re: ZCMD Help - Dayrion - 26.08.2017

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
Код:
CMD:claimcoupon(playerid, params[])
{
    new title[64], msg2[126];//Line 4684
    format(title,sizeof(title),"{1B8AE4}Claim Coupon");
    format(msg2,sizeof(msg2),"Type the coupon code below to\nclaim your reward:");
    ShowPlayerDialog(playerid, coupon1, DIALOG_STYLE_INPUT, title, msg2, "Claim", "Cancel");
    return 1;
}
public HouseEnter(playerid, houseid)
{
    if(PInfo[playerid][House1] == HInfo[houseid][hHouseID]) { new msg2[64]; format(msg2,sizeof(msg2),"Welcome   %s.", PlayerName(playerid)); SendClientMessage(playerid, COLOR_WHITE, msg2); }//Line 3080
    if(PInfo[playerid][House2] == HInfo[houseid][hHouseID]) { new msg2[64]; format(msg2,sizeof(msg2),"Welcome home, %s.", PlayerName(playerid)); SendClientMessage(playerid, COLOR_WHITE, msg2); }
    InHouse[playerid] = houseid;
    SetPlayerInterior(playerid, HInfo[houseid][hInterior]);
    SetPlayerPos(playerid, HInfo[houseid][hiX],HInfo[houseid][hiY],HInfo[houseid][hiZ]);
    SetPlayerVirtualWorld(playerid, houseid);
    return 1;
}
In your script somewhere msg variable was already in use and it was a global variable , So it was conflicting with your those msg variable,
I change your msg variable to msg2, Now it'll works fine.
You don't solve a problem by skirting it. You gave him the solution.
There is a global value or a public variable which is already called msg


Re: ZCMD Help - Vince - 26.08.2017

It may also be an enum specifier or a definition so look for that too.


Re: ZCMD Help - FuNkYTheGreat - 26.08.2017

[quote = Dayrion]You don't solve a problem by skirting it. You gave him the solution.
There is a global value or a public variable which is already called msg[/quote]
Maybe the msg variable that's giving a warning will be in use? Don't you think that, And i already said the reason,
Don't try to act over smart dude !


Respuesta: Re: ZCMD Help - Miguelch1312 - 26.08.2017

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
Код:
CMD:claimcoupon(playerid, params[])
{
    new title[64], msg2[126];//Line 4684
    format(title,sizeof(title),"{1B8AE4}Claim Coupon");
    format(msg2,sizeof(msg2),"Type the coupon code below to\nclaim your reward:");
    ShowPlayerDialog(playerid, coupon1, DIALOG_STYLE_INPUT, title, msg2, "Claim", "Cancel");
    return 1;
}
public HouseEnter(playerid, houseid)
{
    if(PInfo[playerid][House1] == HInfo[houseid][hHouseID]) { new msg2[64]; format(msg2,sizeof(msg2),"Welcome   %s.", PlayerName(playerid)); SendClientMessage(playerid, COLOR_WHITE, msg2); }//Line 3080
    if(PInfo[playerid][House2] == HInfo[houseid][hHouseID]) { new msg2[64]; format(msg2,sizeof(msg2),"Welcome home, %s.", PlayerName(playerid)); SendClientMessage(playerid, COLOR_WHITE, msg2); }
    InHouse[playerid] = houseid;
    SetPlayerInterior(playerid, HInfo[houseid][hInterior]);
    SetPlayerPos(playerid, HInfo[houseid][hiX],HInfo[houseid][hiY],HInfo[houseid][hiZ]);
    SetPlayerVirtualWorld(playerid, houseid);
    return 1;
}
In your script somewhere msg variable was already in use and it was a global variable , So it was conflicting with your those msg variable,
I change your msg variable to msg2, Now it'll works fine.
Thanks everyone, but i have more "New MSG" in my gm, and they never conflicted, the problem appears when i add the ZCMD commands, but if i remove it, the problem disappear. I know why the warnings appear, but i don't know why those ones appears when i add the zcmd, look, there isn't the only warning

GM.pwn(3819) : warning 219: local variable "msg" shadows a variable at a preceding level
GM.pwn(3881) : warning 219: local variable "msg" shadows a variable at a preceding level
GM.pwn(391 : warning 219: local variable "msg" shadows a variable at a preceding level
GM.pwn(3955) : warning 219: local variable "msg" shadows a variable at a preceding level

But if i remove the ZCMDS the warnings disappear.


Re: ZCMD Help - Dayrion - 26.08.2017

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
There is a global value or a public variable which is already called msg
Maybe the msg variable that's giving a warning will be in use? Don't you think that, And i already said the reason,
Don't try to act over smart dude !
Ooh, whoa. I won't appear over smart or anything like that. I'm just pointing the source of this warning (forget to mention enum but Vince did, thanks) and what you adviced it's skirting the warning. It's like doing #pragma tabsize 0 when you don't intend your code mh.
Chill uh