few error with if & else
#1

having a little problem with this code any helped would be great


Код:
C:\Users\GTA ONLY\My Samp Server\gamemodes\MySQL.pwn(347) : warning 209: function "OnPlayerSpawn" should return a value
C:\Users\GTA ONLY\My Samp Server\gamemodes\MySQL.pwn(348) : error 010: invalid function or declaration
C:\Users\GTA ONLY\My Samp Server\gamemodes\MySQL.pwn(351) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Код:
public OnPlayerSpawn(playerid)//337
	{
	new Random = random(sizeof(MdmSpawns));
	new r = random(sizeof(RandomPistol));
	new r1 = random(sizeof(RandomAssault));
	new r2 = random(sizeof(RandomHeavy));
	if(MDM[playerid] != 0) return SetPlayerPos(playerid, MdmSpawns[Random][0], MdmSpawns[Random][1], MdmSpawns[Random][2]);
	GivePlayerWeapon(playerid, RandomPistol[r][0], RandomPistol[r][1]);
	GivePlayerWeapon(playerid, RandomAssault[r1][0], RandomAssault[r1][1]);
	GivePlayerWeapon(playerid, RandomHeavy[r2][0], RandomHeavy[r2][1]);
 }
 else
 {
	 SetPlayerPos(playerid, -2808.0325, -1516.4255, 140.8438), SetPlayerInterior(playerid, 0);
	return 1;
}//352
many thanks
Reply
#2

You have an else that it's useless. Your code should be
pawn Код:
public OnPlayerSpawn(playerid)
{
    new Random = random(sizeof(MdmSpawns));
    new r = random(sizeof(RandomPistol));
    new r1 = random(sizeof(RandomAssault));
    new r2 = random(sizeof(RandomHeavy));
    if(MDM[playerid] != 0) return SetPlayerPos(playerid, MdmSpawns[Random][0], MdmSpawns[Random][1], MdmSpawns[Random][2]);
    GivePlayerWeapon(playerid, RandomPistol[r][0], RandomPistol[r][1]);
    GivePlayerWeapon(playerid, RandomAssault[r1][0], RandomAssault[r1][1]);
    GivePlayerWeapon(playerid, RandomHeavy[r2][0], RandomHeavy[r2][1]);
    return 1;
}
Or should remove this
pawn Код:
return SetPlayerPos(playerid, MdmSpawns[Random][0], MdmSpawns[Random][1], MdmSpawns[Random][2]);
to use the else like this
pawn Код:
public OnPlayerSpawn(playerid)
{
    new r = random(sizeof(RandomPistol));
    new r1 = random(sizeof(RandomAssault));
    new r2 = random(sizeof(RandomHeavy));
    if(MDM[playerid] != 0) {
        GivePlayerWeapon(playerid, RandomPistol[r][0], RandomPistol[r][1]);
        GivePlayerWeapon(playerid, RandomAssault[r1][0], RandomAssault[r1][1]);
        GivePlayerWeapon(playerid, RandomHeavy[r2][0], RandomHeavy[r2][1]);
    }
    else {
        SetPlayerPos(playerid, -2808.0325, -1516.4255, 140.8438), SetPlayerInterior(playerid, 0);
    }
    return 1;
}
Reply
#3

thanks for your help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)