HELPPP!!!
#1

PHP код:
    forward KickPlayer(targetid);
    public 
KickPlayer(targetid)
    {
        
Kick(targetid);
    }
    return 
1;

PHP код:
\\GAMERSHUBTIMERP\Save Here\LGRP\gamemodes\MGRP.pwn(319) : error 029invalid expressionassumed zero
\\GAMERSHUBTIMERP\Save Here\LGRP\gamemodes\MGRP.pwn(319) : error 017undefined symbol "KickPlayer"
\\GAMERSHUBTIMERP\Save Here\LGRP\gamemodes\MGRP.pwn(320) : error 029invalid expressionassumed zero
\\GAMERSHUBTIMERP\Save Here\LGRP\gamemodes\MGRP.pwn(320) : error 017undefined symbol "KickPlayer"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

Reply
#2

https://sampwiki.blast.hk/wiki/Undefined_symbol

read here.

And Show us your enum if you have one
Reply
#3

Quote:
Originally Posted by shourya12
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/Undefined_symbol

read here.

And Show us your enum if you have one
Here's my enum.

Код:
enum PlayerInfo
{
    pPass[129], //User's password
    pAdmin, //User's admin level
    pVIP, //User's vip level
    pMoney, //User's money
    pScores, //User's scores
    pKills, //User's kills
    pDeaths //User's deaths
}
new pInfo[MAX_PLAYERS][PlayerInfo];
EDIT: I don't understand https://sampwiki.blast.hk/wiki/Undefined_symbol.
Reply
#4

@shourya12, nothing in that code relates with the enum or other parts of his code other than that function.

The problem is that you have a bracket too much at the end. Possibly from another function. All your functions should be declared outside the scope of other functions.

This is what it would look like if you had functions declared inside another one:
PHP код:
otherfunction() {
    
forward KickPlayer(playerid);
    public 
KickPlayer(playerid) {
       
Kick(targetid); 
    }
    return 
1;

The example above is completely wrong since you can't declare functions within another function. Thus, we must go outside the scope of all functions to declare them:

PHP код:
otherfunction() {
    return 
1;
}
forward KickPlayer(targetid); 
public 
KickPlayer(targetid

    return 
Kick(targetid); 

Reply
#5

Did u put these functions outside all the functions ?? if not put it let it be @ bottom of script like this

Quote:

forward KickPlayer(targetid);
public KickPlayer(targetid)
{
Kick(targetid);
}

Reply
#6

None are working

My full script. Please fix it for me.

PHP код:
CMD:kick(playeridparams[])
{
    if(
pInfo[playerid][pAdmin] < 1)
        return 
SendClientMessage(playeridGREY"You are not authorized to use that command.");
        
    new
        
targetid,
        
Reason[128],
        
str[128]
    ;
    
    if(
sscanf(params"us[128]"targetidReason))
        return 
SendClientMessage(playeridGREY"USAGE: /kick [Playerid] [Reason]");
        
    if(!
IsPlayerConnected(targetid))
        return 
SendClientMessage(playeridGREY"Player is not connected.");
        
    new
        
pname[MAX_PLAYER_NAME],
        
tname[MAX_PLAYER_NAME]
    ;
    
    
GetPlayerName(playeridpnamesizeof(pname));
    
GetPlayerName(targetidtnamesizeof(tname));
    
    
format(strsizeof(str), "You have been kicked by %s REASON: %s."tnameReason);
    
SendClientMessage(targetidREDstr);
    
format(strsizeof(str), "You have kicked %s REASON: %s."pnameReason);
    
SendClientMessage(playeridREDstr);
    
    
SetTimerEx("KickPlayer"1000false"i"targetid);
    
    
forward KickPlayer(targetid);
    public 
KickPlayer(targetid)
    {
         
Kick(targetid);
    }
    return 
1;

Reply
#7

Код:
CMD:kick(playerid, params[]) 
{ 
    if(pInfo[playerid][pAdmin] < 1) 
        return SendClientMessage(playerid, GREY, "You are not authorized to use that command."); 
         
    new 
        targetid, 
        Reason[128], 
        str[128] 
    ; 
     
    if(sscanf(params, "us[128]", targetid, Reason)) 
        return SendClientMessage(playerid, GREY, "USAGE: /kick [Playerid] [Reason]"); 
         
    if(!IsPlayerConnected(targetid)) 
        return SendClientMessage(playerid, GREY, "Player is not connected."); 
         
    new 
        pname[MAX_PLAYER_NAME], 
        tname[MAX_PLAYER_NAME] 
    ; 
     
    GetPlayerName(playerid, pname, sizeof(pname)); 
    GetPlayerName(targetid, tname, sizeof(tname)); 
     
    format(str, sizeof(str), "You have been kicked by %s REASON: %s.", tname, Reason); 
    SendClientMessage(targetid, RED, str); 
    format(str, sizeof(str), "You have kicked %s REASON: %s.", pname, Reason); 
    SendClientMessage(playerid, RED, str); 
     
    SetTimerEx("KickPlayer", 1000, false, "i", targetid);     
    return 1; 
}

forward KickPlayer(targetid); 
public KickPlayer(targetid) 
{ 
     Kick(targetid); 
}
Reply
#8

Quote:
Originally Posted by iCurse
Посмотреть сообщение
None are working..
I don't think you understand the difference between the command & the function, you need to completely separate both, what you did above is mixing both of them into one code which clearly doesn't/won't work.

Код:
CMD:kick(playerid, params[])
{
	if(pInfo[playerid][pAdmin] < 1)
	    return SendClientMessage(playerid, GREY, "You are not authorized to use that command.");
	    
	new
	    targetid,
		Reason[128],
		str[128]
	;
	
	if(sscanf(params, "us[128]", targetid, Reason))
	    return SendClientMessage(playerid, GREY, "USAGE: /kick [Playerid] [Reason]");
	    
	if(!IsPlayerConnected(targetid))
	    return SendClientMessage(playerid, GREY, "Player is not connected.");
	    
	new
	    pname[MAX_PLAYER_NAME],
	    tname[MAX_PLAYER_NAME]
	;
	
	GetPlayerName(playerid, pname, sizeof(pname));
	GetPlayerName(targetid, tname, sizeof(tname));
	
	format(str, sizeof(str), "You have been kicked by %s REASON: %s.", tname, Reason);
	SendClientMessage(targetid, RED, str);
	format(str, sizeof(str), "You have kicked %s REASON: %s.", pname, Reason);
	SendClientMessage(playerid, RED, str);
	
	SetTimerEx("KickPlayer", 1000, false, "i", targetid);

	return 1;
}



    forward KickPlayer(targetid); 
    public KickPlayer(targetid) 
    { 
         return Kick(targetid); 
    }
That's how it should look, if you have more commands below the kick command, then scroll to the bottom of your game mode and place the KickPlayer function.

"CMD: something(playerid, params[])" <- is a command.
"public something()" <- is a function.
Reply
#9

Quote:
Originally Posted by -CaRRoT
Посмотреть сообщение
"public something()" <- is a function.
So you mean functions always starts with public?
Reply
#10

Quote:
Originally Posted by iCurse
Посмотреть сообщение
So you mean functions always starts with public?
No thats not what he meant the functions can have different keywords like public stock static etc or nothing here we are usnig public 'cause the settimerex works on public functions
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)