SA-MP Forums Archive
/eventprize 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: /eventprize help (/showthread.php?tid=399332)



/eventprize help - MichaelWharton101 - 14.12.2012

I am trying to make a command for a event prize but get a error.

Script
Код:
CMD:eventprize(playerid, params[])
{
	new string[128], playerb, prize,;
   	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
   	if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
	if(sscanf(params, "ui", playerb, event))
	{
		SendClientMessage(playerid, COLOR_WHITE, "/setstat [playerid] [prizeid]");
		SendClientMessage(playerid, COLOR_GREY, "Prizes: 1 | 2");
		return 1;
	}
	if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
	switch(stat)
	{
	    case 1:
	    {
	        GiveZaiatMoney(playerid, 50000);
         	SetPlayerHealth(playerid, 100);
        	SetPlayerArmour(playerid, 100);
		format(string, sizeof(string), "%s has givin %s $50,000 and full health and armor", RPN(playerid), RPN(playerb));
		SendClientMessageToAll(COLOR_LIGHTRED, string);
	    }
	}
	Log("logs/eventprize.log", string);
	return 1;
}
Error:
Код:
C:\Users\Michael\Desktop\*\other\GTA\My server\ARP\gamemodes\ARP.pwn(3431) : error 001: expected token: "-identifier-", but found ";"
C:\Users\Michael\Desktop\*\other\GTA\My server\ARP\gamemodes\ARP.pwn(3434) : error 017: undefined symbol "event"
C:\Users\Michael\Desktop\*\other\GTA\My server\ARP\gamemodes\ARP.pwn(3441) : error 017: undefined symbol "stat"
C:\Users\Michael\Desktop\*\other\GTA\My server\ARP\gamemodes\ARP.pwn(3431) : warning 203: symbol is never used: "prize"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.



Re: /eventprize help - LarzI - 14.12.2012

You haven't declared the variables "event" and "stats".
You have an extra comma at the declaration of "prize" - remove it.
You have never used the variable "prize", so unless you intend to: Remove it.


Re: /eventprize help - MichaelWharton101 - 14.12.2012

hmmm I got it down to this.

Код:
C:\Users\Michael\Desktop\*\other\GTA\My server\ARP\gamemodes\ARP.pwn(3434) : error 017: undefined symbol "event"
C:\Users\Michael\Desktop\*\other\GTA\My server\ARP\gamemodes\ARP.pwn(3441) : error 017: undefined symbol "stat"
C:\Users\Michael\Desktop\*\other\GTA\My server\ARP\gamemodes\ARP.pwn(3431) : warning 203: symbol is never used: "prize"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: /eventprize help - maramizo - 14.12.2012

pawn Код:
CMD:eventprize(playerid, params[])
{
    new string[128], playerb, event; //Prize is not needed, event is.
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "ui", playerb, event))
    {
        SendClientMessage(playerid, COLOR_WHITE, "/setstat [playerid] [prizeid]");
        SendClientMessage(playerid, COLOR_GREY, "Prizes: 1 | 2");
        return 1;
    }
    if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    switch(event) //Switching on Event, not "Stat", as there is no such thing as "Stat" defined.
    {
        case 1:
        {
            GiveZaiatMoney(playerb, 50000); //This
            SetPlayerHealth(playerb, 100); //This
            SetPlayerArmour(playerb, 100); //And this were wrong, you're giving the prize to playerb, not the player who types in the command.
            format(string, sizeof(string), "%s has givin %s $50,000 and full health and armor", RPN(playerid), RPN(playerb));
            SendClientMessageToAll(COLOR_LIGHTRED, string);
        }//Where's case 2?
    }
    Log("logs/eventprize.log", string);
    return 1;
}



Re: /eventprize help - LarzI - 14.12.2012

So clearly you read the second line in my reply, but ignored the first and third.


Re: /eventprize help - MichaelWharton101 - 14.12.2012

Quote:
Originally Posted by maramizo
Посмотреть сообщение
pawn Код:
CMD:eventprize(playerid, params[])
{
    new string[128], playerb, event; //Prize is not needed, event is.
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "ui", playerb, event))
    {
        SendClientMessage(playerid, COLOR_WHITE, "/setstat [playerid] [prizeid]");
        SendClientMessage(playerid, COLOR_GREY, "Prizes: 1 | 2");
        return 1;
    }
    if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    switch(event) //Switching on Event, not "Stat", as there is no such thing as "Stat" defined.
    {
        case 1:
        {
            GiveZaiatMoney(playerb, 50000); //This
            SetPlayerHealth(playerb, 100); //This
            SetPlayerArmour(playerb, 100); //And this were wrong, you're giving the prize to playerb, not the player who types in the command.
            format(string, sizeof(string), "%s has givin %s $50,000 and full health and armor", RPN(playerid), RPN(playerb));
            SendClientMessageToAll(COLOR_LIGHTRED, string);
        }//Where's case 2?
    }
    Log("logs/eventprize.log", string);
    return 1;
}
I see but now when I go IG and type /eventprize 1 it does not give the prize.

NVM fixed