SA-MP Forums Archive
Why this is wrong? - 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: Why this is wrong? (/showthread.php?tid=440763)



Why this is wrong? - RalphHaro - 31.05.2013

What did I do wrong in this code guys? Help please.
PHP код:
CMD:god(playeridparams[])
{
    if(
IsPlayerConnected(playerid))
    if(!
aDuty[playerid]) return SendClientMessage(playeridCOLOR_GREY"You are not on Admin Duty.");
     if(
PlayerInfo[playerid][pAdmin] < 2) {
      
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use that command!");
       return 
1;
     }
     if(
GodMode[playerid] == 0)
     
SendClientMessage(playeridCOLOR_GREY"You are now in God Mode!");
    {
        
SetPlayerHealth(playerid999999);
        
SetPlayerArmour(playerid999999);
    }
    else if(
GodMode[playerid] == 1)
    
SendClientMessage(playeridCOLOR_GREY"You have turned off your God Mode!");
    {
        
SetPlayerHealth(playerid100);
        
SetPlayerArmour(playerid100);
    }
    return 
1;

This is the errors.
Код:
C:\Documents and Settings\USER\Desktop\HGRP\gamemodes\HGRP.pwn(44513) : error 029: invalid expression, assumed zero
C:\Documents and Settings\USER\Desktop\HGRP\gamemodes\HGRP.pwn(44513) : warning 215: expression has no effect
C:\Documents and Settings\USER\Desktop\HGRP\gamemodes\HGRP.pwn(44513) : error 001: expected token: ";", but found "if"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: Why this is wrong? - Knight_Rider - 31.05.2013

Код:
CMD:god(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 2)
	{
		SetPlayerHealth(playerid, 100000);
		SetPlayerArmour(playerid, 100000);
	}
	return 1;
}
Simple one ._.


Re: Why this is wrong? - BossZk - 31.05.2013

try this

PHP код:
CMD:god(playeridparams[])
{
    if(
IsPlayerConnected(playerid))
    {
    if(!
aDuty[playerid]) return SendClientMessage(playeridCOLOR_GREY"You are not on Admin Duty.");
       if(
PlayerInfo[playerid][pAdmin] < 2)
    {
        
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use that command!");
        return 
1;
    }
       if(
GodMode[playerid] == 0)
    {
        
SendClientMessage(playeridCOLOR_GREY"You are now in God Mode!");
        
SetPlayerHealth(playerid999999);
        
SetPlayerArmour(playerid999999);
    }
    else if(
GodMode[playerid] == 1)
    {
        
SendClientMessage(playeridCOLOR_GREY"You have turned off your God Mode!");
        
SetPlayerHealth(playerid100);
        
SetPlayerArmour(playerid100);
    }
    }
    return 
1;

when you put if(GodMode[playerid] == 0)
dont put sendclientmessage right after then, put it in the brackets along with the setplayerhealth and armour


Re: Why this is wrong? - RalphHaro - 31.05.2013

Quote:
Originally Posted by BossZk
Посмотреть сообщение
try this

PHP код:
CMD:god(playeridparams[])
{
    if(
IsPlayerConnected(playerid))
    {
    if(!
aDuty[playerid]) return SendClientMessage(playeridCOLOR_GREY"You are not on Admin Duty.");
       if(
PlayerInfo[playerid][pAdmin] < 2)
    {
        
SendClientMessage(playeridCOLOR_GREY"You are not authorized to use that command!");
        return 
1;
    }
       if(
GodMode[playerid] == 0)
    {
        
SendClientMessage(playeridCOLOR_GREY"You are now in God Mode!");
        
SetPlayerHealth(playerid999999);
        
SetPlayerArmour(playerid999999);
    }
    else if(
GodMode[playerid] == 1)
    {
        
SendClientMessage(playeridCOLOR_GREY"You have turned off your God Mode!");
        
SetPlayerHealth(playerid100);
        
SetPlayerArmour(playerid100);
    }
    }
    return 
1;

when you put if(GodMode[playerid] == 0)
dont put sendclientmessage right after then, put it in the brackets along with the setplayerhealth and armour
THANKS +REP


Re: Why this is wrong? - Giroud12 - 31.05.2013

This is not god mode,player can die if you make like this.

Your Code
pawn Код:
SetPlayerHealth(playerid, 999999);
If you use like this,player wont die forever until the godmode off.

Define
pawn Код:
#define INFINITE                (Float:0x7F800000)
Replace
pawn Код:
SetPlayerHealth(playerid, INFINITE);