SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 15/05/2012, 06:21 AM   #1
newbienoob
High-roller
 
newbienoob's Avatar
 
Join Date: Jan 2012
Location: Follow the moaning coming from your parents' bedroom
Posts: 1,530
Reputation: 270
Default Need help fixing bugs

1) I can't enter all the vehicles
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new veh = GetPlayerVehicleID(playerid);
    new score = GetPlayerScore(playerid);
    new Float:x,Float:y,Float:z;
    if(veh == 520 && score < 350)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 4 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 425 && score < 600)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be Level 5 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 447 && veh == 432 || score < 150)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 3 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 476 && score < 50)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 2 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    return 1;
}

2) I'm Los Santos gang member. But I can see a message says "[WARNING]You have entered San Fierro Area". But I'm at Los Santos.
pawn Code:
public OnPlayerEnterArea(playerid, areaid)
{
    new gang = GetPlayerTeam(playerid);
    if(areaid == lsarea && gang == Las_Venturas_Gang_Members && gang == San_Fierro_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered Los Santos Area");
        return 1;
    }
    else if(areaid == sfarea || gang == Las_Venturas_Gang_Members || gang == Los_Santos_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered San Fierro Area");
        return 1;
    }
    else if(areaid == lvarea || gang == San_Fierro_Gang_Members || gang == Los_Santos_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered Las Venturas Area");
        return 1;
    }
    return 1;
}
__________________
Help me, please /a chat
newbienoob is offline   Reply With Quote
Old 15/05/2012, 07:07 AM   #2
[ABK]Antonio
High-roller
 
[ABK]Antonio's Avatar
 
Join Date: Sep 2011
Location: ID, USA
Posts: 1,223
Reputation: 187
Default Re: Need help fixing bugs

Quote:
Originally Posted by newbienoob View Post
1) I can't enter all the vehicles
pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new veh = GetPlayerVehicleID(playerid);
    new score = GetPlayerScore(playerid);
    new Float:x,Float:y,Float:z;
    if(veh == 520 && score < 350)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 4 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 425 && score < 600)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be Level 5 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 447 && veh == 432 || score < 150)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 3 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    else if(veh == 476 && score < 50)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 2 to use this vehicle");
        GetPlayerPos(playerid,x,y,z);
        SetPlayerPos(playerid,x,y,z);
        RemovePlayerFromVehicle(playerid);
        return 1;
    }
    return 1;
}

2) I'm Los Santos gang member. But I can see a message says "[WARNING]You have entered San Fierro Area". But I'm at Los Santos.
pawn Code:
public OnPlayerEnterArea(playerid, areaid)
{
    new gang = GetPlayerTeam(playerid);
    if(areaid == lsarea && gang == Las_Venturas_Gang_Members && gang == San_Fierro_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered Los Santos Area");
        return 1;
    }
    else if(areaid == sfarea || gang == Las_Venturas_Gang_Members || gang == Los_Santos_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered San Fierro Area");
        return 1;
    }
    else if(areaid == lvarea || gang == San_Fierro_Gang_Members || gang == Los_Santos_Gang_Members)
    {
        SendClientMessage(playerid,0xFF0000FF,"[WARNING]You have entered Las Venturas Area");
        return 1;
    }
    return 1;
}
#1

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new model = GetVehicleModel(vehicleid),
        score = GetPlayerScore(playerid);

    if(model == 520 && score < 350)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 4 to use this vehicle");
        ClearAnimations(playerid);
    }
    else if(model == 425 && score < 600)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be Level 5 to use this vehicle");
        ClearAnimations(playerid);
    }
    else if(model = 476 && score < 50)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 2 to use this vehicle");
        ClearAnimations(playerid);
    }
    else if((model == 447 || model == 432) && score < 150)
    {
        SendClientMessage(playerid,0xFF0000FF,"You need to be at least Level 3 to use this vehicle");
        ClearAnimations(playerid);
    }
    return 1;
}

As you can see I've changed the last one there. Instead of || score < 150 What || score < 150 was doing was making it so if you don't have a score more than 150, you can't enter ANY vehicle. Also, you were doing if those two vehicle ids were exactly the same...Which won't happen. Another thing to note is, players don't actually have a vehicle ID yet as they haven't gotten into the vehicle. That would be something for OnPlayerStateChange then remove them instead of reset their position.


#2 I don't know what's going on in there...You have some gang variable that's global that will constantly change from player to play becoming a completely useless variable. You should look for tutorials on arrays for that one.
__________________

ABKClan.com
[ABK]Antonio is offline   Reply With Quote
Old 15/05/2012, 08:03 AM   #3
newbienoob
High-roller
 
newbienoob's Avatar
 
Join Date: Jan 2012
Location: Follow the moaning coming from your parents' bedroom
Posts: 1,530
Reputation: 270
Default Re: Need help fixing bugs

Ok thanks
__________________
Help me, please /a chat
newbienoob is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with fixing a Job. rangerxxll Scripting Help 1 25/02/2012 06:04 AM
Fixing some bugs... Gooday Scripting Help 0 27/12/2011 04:57 PM
Fixing SWRP bugs' Scripter needed' x Aviator Help Archive 0 28/03/2010 06:23 PM
I downloaded LSLRP and i need help fixing some bugs ;/ Karl115 Help Archive 2 03/02/2010 08:17 PM


All times are GMT. The time now is 08:58 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.