easydialog
#1

i compile the code and i get the error

PHP Code:
Dialog:RandomDM(playeridresponselistiteminputtext[])
{
    new 
string[128], playerName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayerNamesizeof(playerName));
    if (
response)
    {
        switch(
listitem// Check which option was chosen when they responded. We only have one for now. The next would be case 1, then case 2 and so on.
            
{
                case 
0:
                {
                    
InDM[playerid] = true;
                    
DM[playerid] = 0;
                    
SpawnPlayer(playerid);
                }
            }
            
format(stringsizeof(string), "{77B3D9}[DM Zones] {ffffff}%s(%i) has just entered {77B3D9}DM zone %i {ffffff}(/dm)"playerNameplayeridDM[playerid]);
            
SendClientMessageToAll(-1string);
            return 
1;
        }
    } 
//error code
    
return 0;//error code

the error

Quote:

C:\Users\cyber\Desktop\gta server cc bukit\gamemodes\GL.pwn(4154) : warning 209: function "dialog_RandomDM" should return a value
C:\Users\cyber\Desktop\gta server cc bukit\gamemodes\GL.pwn(4155) : error 010: invalid function or declaration
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.

Reply
#2

Why do you use return 0?
Reply
#3

it must remove return 0 ?

im nubis scripter
Reply
#4

Because you forget a bracket

PHP Code:
Dialog:RandomDM(playeridresponselistiteminputtext[]) 

    new 
string[128], playerName[MAX_PLAYER_NAME]; 
    
GetPlayerName(playeridplayerNamesizeof(playerName)); 
    if (
response
    { 
        switch(
listitem// Check which option was chosen when they responded. We only have one for now. The next would be case 1, then case 2 and so on. 
            

                case 
0
                { 
                    
InDM[playerid] = true
                    
DM[playerid] = 0
                    
SpawnPlayer(playerid); 
                } 
            } 
            
format(stringsizeof(string), "{77B3D9}[DM Zones] {ffffff}%s(%i) has just entered {77B3D9}DM zone %i {ffffff}(/dm)"playerNameplayeridDM[playerid]); 
            
SendClientMessageToAll(-1string); 
            return 
1
        }  
// ?? One you missed
    

    return 
0;

Reply
#5

One too many, rather. There are 4 opening braces and 5 closing braces.
Reply
#6

Also return 1 instead of 0
Reply
#7

it fixed

PHP Code:
Dialog:RandomDM(playeridresponselistiteminputtext[])
{
    new 
string[128], playerName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayerNamesizeof(playerName));
    if (
response)
    {
        switch(
listitem// Check which option was chosen when they responded. We only have one for now. The next would be case 1, then case 2 and so on.
            
{
                case 
0:
                {
                    
InDM[playerid] = true;
                    
DM[playerid] = 0;
                    
SpawnPlayer(playerid);
                }
            }
            
format(stringsizeof(string), "{77B3D9}[DM Zones] {ffffff}%s(%i) has just entered {77B3D9}DM zone %i {ffffff}(/dm)"playerNameplayeridDM[playerid]);
            
SendClientMessageToAll(-1string);
            return 
1;  // ?? One you missed
    
}
    return 
0;

but i start the server
it show this
Quote:

[11:15:07] [debug] Run time error 4: "Array index out of bounds"
[11:15:07] [debug] Attempted to read/write array element at index 65535 in array of size 1000
[11:15:07] [debug] AMX backtrace:
[11:15:07] [debug] #0 0001facc in ?? (0, 65535, 54) from GL.amx
[11:15:07] [debug] #1 0000c4b4 in public OnPlayerDeath (0, 65535, 54) from GL.amx

Reply
#8

^^ Clearly says 'OnPlayerDeath', there's something wrong with that, probably you're not checking the killierid is valid or not.
Reply
#9

this my onplayerdeath

PHP Code:
public OnPlayerDeath(playeridkilleridreason)
{
 
SendDeathMessage(killeridplayeridreason);
 
SetPlayerScore(killeridGetPlayerScore(killerid)+ 1);
 
    
PlayerTextDrawHide(playerid,Textdraw0);
    
PlayerTextDrawHide(playerid,Textdraw1);
    
PlayerTextDrawHide(playerid,Textdraw2);
    
PlayerTextDrawHide(playerid,Textdraw3);
    new 
playercash;
    
    
// if they ever return to class selection make them city
    // select again first
    
gPlayerHasCitySelected[playerid] = 0;
    
    
god_mode[playerid] = 0;
    
    if(
IsPlayerConnected(killerid) && killerid != INVALID_PLAYER_ID)
      {
             if(
GetPlayerWantedLevel(killerid) < 6)
        {
              
SetPlayerWantedLevel(killeridGetPlayerWantedLevel(killerid) + 1);
         }
            
KillStreak[killerid]++;
            
GivePlayerMoney(killerid1000);
      }
    
SetPlayerWantedLevel(playerid,0);
        
KillStreak[playerid] = 0;
    new 
str[256], PlayerName[MAX_PLAYER_NAME];
    
GetPlayerName(killeridPlayerNamesizeof(PlayerName));
        switch( 
KillStreakkillerid ] )
{
    case 
1//You wouldn't really count 1 kill as a streak but it gives you an idea
    
{
        
format(strsizeof(str), "~r~ %s is on a kill!"PlayerName);
        
GameTextForAll(str,4000,6);
    }
    case 
2:
    {
        
format(strsizeof(str), "~r~ %s is on a ~b~double kill!"PlayerName);
        
GameTextForAll(str,4000,6);
    }
    case 
3:
    {
        
format(strsizeof(str), "~y~%s is on a ~r~killing spree!"PlayerName);
        
GameTextForAll(str,4000,6);
    }
    case 
4:
    {
        
format(strsizeof(str), "~g~%s is on a ~b~mmmmmonster kill!"PlayerName);
        
GameTextForAll(str,4000,6);
    }
    case 
5:
    {
        
format(strsizeof(str), "~r~%s is ~p~dominating!"PlayerName);
        
GameTextForAll(str,4000,6);
    }
    case 
6:
    {
        
format(strsizeof(str), "~p~%s is ~y~unstopable!"PlayerName);
        
GameTextForAll(str,4000,6);
    }
    case 
7//You can do this as many times as you like
    
{
        
format(str,sizeof(str),"%s is annihilating!",PlayerName);
        
GameTextForAll(str,4000,6);
    }
    case 
10:
    {
        
format(str,sizeof(str),"%s is GodLike!",PlayerName);
        
GameTextForAll(str,4000,6);
    }
}
    new 
string[128],
  
name[MAX_PLAYER_NAME],
  
killername[MAX_PLAYER_NAME];
  
GetPlayerName(playeridnamesizeof(name));
  
GetPlayerName(killeridkillernamesizeof(killername));
  
GetWeaponName(reasonstringsizeof(string));
  
format(stringsizeof(string), "* %s killed %s by using his/her %s."killername[playerid], name[killerid], string);
  
SendClientMessageToAll(COLOR_MAROONstring);
    if(
killerid == INVALID_PLAYER_ID){
        
ResetPlayerMoney(playerid);
    } else {
        
playercash GetPlayerMoney(playerid);
        if(
playercash 0)  {
            
GivePlayerMoney(killeridplayercash);
            
ResetPlayerMoney(playerid);
        }
    }
       return 
1;

Reply
#10

Can you do it yourself for the sake of your existence? You just need to add an 'if' statement which checks killerid is invalid or not, if it's not same then it calls the killerid part of the code...

EDIT: Also, for fuck sake, indent your fucking code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)