Problem with vehicle spawning.
#1

Okay, I have made VIP System and Admin System. I made it like, when someone tries to spawn a hunter, hydra, or a rhino, it'll send him "Only VIP's / Admins can spawn 'carname'". But, I can't even spawn an infernus. Even though my admin level is 5. (max). I can't spawn hunters, hydras, rhinos too. But, When I set my VIP level to 1 or more. I can spawn everything



This is my vehicle spawner
pawn Код:
function CreatePlayerVehicle(playerid, modelid)
{
    if(modelid == 432 && PlayerInfo[playerid][pAdminLevel] == 0 || PlayerInfo[playerid][pVIPLevel] == 0)
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] "GREY"Only VIP's/Admins can spawn Rhino's!");
        PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
        return 0;
    }
    if(modelid  == 425 && PlayerInfo[playerid][pAdminLevel] == 0 || PlayerInfo[playerid][pVIPLevel] == 0)
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] "GREY"Only VIP's/Admins can spawn Hunter's!");
        PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
        return 0;
    }
    if(modelid  == 520 && PlayerInfo[playerid][pAdminLevel] == 0 || PlayerInfo[playerid][pVIPLevel] == 0)
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] "GREY"Only VIP's/Admins can spawn Hydra's!");
        PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
        return 0;
    }
    if(PlayerInfo[playerid][PlayerCar] != -1 && !IsVehicleOccupied(PlayerInfo[playerid][PlayerCar]))
    {
        DestroyVehicle(PlayerInfo[playerid][PlayerCar]);
        PlayerInfo[playerid][PlayerCar] = -1;
    }
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerFacingAngle(playerid, a);
    GetPlayerPos(playerid, x, y, z);

    PlayerInfo[playerid][PlayerCar] = CreateVehicle(modelid, x, y, z, a, random(255), random(255), -1);
    SetVehicleVirtualWorld(PlayerInfo[playerid][PlayerCar],GetPlayerVirtualWorld(playerid));
    LinkVehicleToInterior(PlayerInfo[playerid][PlayerCar], GetPlayerInterior(playerid));
    PutPlayerInVehicle(playerid, PlayerInfo[playerid][PlayerCar], 0);
    return PlayerInfo[playerid][PlayerCar];
}
Reply
#2

Use switch, which is less complicated than using if statement.

pawn Код:
switch(modelid)
{
     case 432: { if(!PlayerInfo[playerid][pAdminLevel]) } // Player is not an admin.
     case 425: { if(!PlayerInfo[playerid][pAdminLevel]) }
}
Reply
#3

I'd like to make them for VIP's aswell.

So, will it be:

pawn Код:
switch(modelid)
{
     case 432: { if(!PlayerInfo[playerid][pAdminLevel] || !PlayerInfo[playerid][pVIPLevel]) } // Player is not an admin.
     case 425: { if(!PlayerInfo[playerid][pAdminLevel] || !PlayerInfo[playerid][pVIPLevel]) }
}
?
Reply
#4

Now, I'm able to spawn everything. But, I can't spawn hydra, rhino, hunter even when i'm an VIP & admin.
Current code:
pawn Код:
switch(modelid)
    {
        case 432:
        {
            if(PlayerInfo[playerid][pAdminLevel] == 0 || PlayerInfo[playerid][pVIPLevel] == 0)
            {
                SendClientMessage(playerid,COLOR_RED,"[ERROR] "GREY"Only VIP's/Admins can spawn Rhinos!");
                return 0;
            }
        }
        case 425:
        {
            if(PlayerInfo[playerid][pAdminLevel] == 0 || PlayerInfo[playerid][pVIPLevel] == 0)
            {
                SendClientMessage(playerid,COLOR_RED,"[ERROR] "GREY"Only VIP's/Admins can spawn Hunters!");
                return 0;
            }
        }
        case 520:
        {
            if(PlayerInfo[playerid][pAdminLevel] == 0 || PlayerInfo[playerid][pVIPLevel] == 0)
            {
                SendClientMessage(playerid,COLOR_RED,"[ERROR] "GREY"Only VIP's/Admins can spawn Hydras!");
                return 0;
            }
        }
    }
If it's wrong, I request you to correct my code please.

Thanks in advance!
Reply
#5

try to change

pawn Код:
return 0;
to

pawn Код:
return 1;
then check
Reply
#6

at first please define this
Quote:

stock IsPlayerMod(playerid,lvl)
{
if(PlayerInfo[playerid][pAdminLevel]>=lvl) return 1;
return 0;
}
stock IsPlayerModEx(playerid,lvl)
{
if(PlayerInfo[playerid][pAdminLevel]==lvl) return 1;
return 0;
}

then use this conditional signs in ur script !
Reply
#7

pawn Код:
function CreatePlayerVehicle(playerid, modelid)
{
    if(modelid == 432 && PlayerInfo[playerid][pAdminLevel] == 0 && PlayerInfo[playerid][pVIPLevel] == 0)
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] "GREY"Only VIP's/Admins can spawn Rhino's!");
        PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
        return 0;
    }
    if(modelid  == 425 && PlayerInfo[playerid][pAdminLevel] == 0 && PlayerInfo[playerid][pVIPLevel] == 0)
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] "GREY"Only VIP's/Admins can spawn Hunter's!");
        PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
        return 0;
    }
    if(modelid  == 520 && PlayerInfo[playerid][pAdminLevel] == 0 && PlayerInfo[playerid][pVIPLevel] == 0)
    {
        SendClientMessage(playerid,COLOR_RED,"[ERROR] "GREY"Only VIP's/Admins can spawn Hydra's!");
        PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
        return 0;
    }
    if(PlayerInfo[playerid][PlayerCar] != -1 && !IsVehicleOccupied(PlayerInfo[playerid][PlayerCar]))
    {
        DestroyVehicle(PlayerInfo[playerid][PlayerCar]);
        PlayerInfo[playerid][PlayerCar] = -1;
    }
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerFacingAngle(playerid, a);
    GetPlayerPos(playerid, x, y, z);

    PlayerInfo[playerid][PlayerCar] = CreateVehicle(modelid, x, y, z, a, random(255), random(255), -1);
    SetVehicleVirtualWorld(PlayerInfo[playerid][PlayerCar],GetPlayerVirtualWorld(playerid));
    LinkVehicleToInterior(PlayerInfo[playerid][PlayerCar], GetPlayerInterior(playerid));
    PutPlayerInVehicle(playerid, PlayerInfo[playerid][PlayerCar], 0);
    return PlayerInfo[playerid][PlayerCar];
}
Try this, you have "||" when you check if player is VIP, "||" means "or" and "&&" means "and".
Reply
#8

It worked! Thanks for your help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)