SA-MP Forums Archive
Quick Command Help Needed - 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: Quick Command Help Needed (/showthread.php?tid=371112)



Quick Command Help Needed - UnknownGamer - 22.08.2012

Hello again,

I've got stuck on another command refusing to work, just simply trying to define the username of the person who does "/ready"

Код:
    // NEW GUN RELOAD COMMAND - MADE BY MATT //
    if(strcmp(cmd, "/ready", true) == 0)
    {
        // Gets the players name
        new string1[256], sendername[MAX_PLAYER_NAME];

        // The animations for the reload guns.
		OnePlayAnim(playerid,"UZI","UZI_reload",4.0,0,0,0,0,0);

		// Sends the client message, to all.
		format(string1, sizeof(string1), "%s has clicked off his safety.", sendername);
		ProxDetector(30.0, playerid, string1, COLOR_LIGHTBLUE);

    	return 1;
    }
	// END OF NEW RELOAD GUN COMMAND //
Errors:
Код:
C:\Users\matthew\Desktop\Sep 2012\gamemodes\larp.pwn(27923) : warning 219: local variable "sendername" shadows a variable at a preceding level
C:\Users\matthew\Desktop\Sep 2012\gamemodes\larp.pwn(27930) : warning 202: number of arguments does not match definition
C:\Users\matthew\Desktop\Sep 2012\gamemodes\larp.pwn(27930) : warning 202: number of arguments does not match definition
C:\Users\matthew\Desktop\Sep 2012\gamemodes\larp.pwn(27930) : warning 202: number of arguments does not match definition
C:\Users\matthew\Desktop\Sep 2012\gamemodes\larp.pwn(27930) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Warnings.
Please can somebody write me the fixed command?

Thanks


Re: Quick Command Help Needed - clarencecuzz - 22.08.2012

pawn Код:
// NEW GUN RELOAD COMMAND - MADE BY MATT //
    if(strcmp(cmd, "/ready", true) == 0)
    {
        // Gets the players name
        new string1[256], sendname[MAX_PLAYER_NAME];

        // The animations for the reload guns.
        OnePlayAnim(playerid,"UZI","UZI_reload",4.0,0,0,0,0,0);

        // Sends the client message, to all.
        format(string1, sizeof(string1), "%s has clicked off his safety.", sendname);
        ProxDetector(30.0, playerid, string1, COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE,COLOR_LIGHTBLUE);

        return 1;
    }
    // END OF NEW RELOAD GUN COMMAND //
-You have the variable 'sendername' in another place, possibly the same code space that is interfering, so you are introducing a new variable called sendername twice. There are two alternatives, renaming one of the variables or removing the other variable with caution, being aware not to break any code.

-There are 5 colours in a ProxDetector function. (So I've been told. Not tested)
Код:
ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);



Re: Quick Command Help Needed - UnknownGamer - 22.08.2012

Thankyou. I got it working now.

Anybody who may want the script, working code is.

Код:
    // NEW GUN RELOAD COMMAND - MADE BY MATT //
    if(strcmp(cmd, "/ready", true) == 0)
    {
        // Defines the string
        new string1[256];

        // The animations for the reload guns.
		OnePlayAnim(playerid,"UZI","UZI_reload",4.0,0,0,0,0,0);

		// Sends the client message, to all.
		format(string1, sizeof(string1),"%s has clicked off his safety.", sendername);
		SendClientMessageToAll(COLOR_LIGHTBLUE, string1);

		format(string1, sizeof(string1),"%s reloads his weapon.", sendername);
		SendClientMessageToAll(COLOR_LIGHTBLUE, string1);

    	return 1;
    }
	// END OF NEW RELOAD GUN COMMAND //