SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 26/07/2013, 10:50 AM   #11
JusstinRoller
Big Clucker
 
JusstinRoller's Avatar
 
Join Date: Jul 2013
Posts: 99
Reputation: -4
Default Re: OnPlayerStateChange

PHP Code:
stock MechanicCar(vehicleid)
{
    for(new 
i;<= sizeof(TowTrucks);i++)
    {
        if(
vehicleid == TowTrucks[i]) 
        {
            return 
1;
        }
    }
    return 
1;

JusstinRoller is offline   Reply With Quote
Old 26/07/2013, 11:20 AM   #12
Muhamed.pwn
Big Clucker
 
Join Date: Mar 2012
Posts: 67
Reputation: 0
Default Re: OnPlayerStateChange

Quote:
Originally Posted by BenzoAMG View Post
Did you change GetPlayerState(playerid) to newstate?
Make sure you copy my code exactly.

If that doesn't work, then the problem is most likely in your 'TowTrucks' array.

Tried 'newstate', TowTrucks works perfect, when I put MechanicCar first and BusCar under it then BusCar won't work!

JusstinRoller, tried with yours, still no luck.
Muhamed.pwn is offline   Reply With Quote
Old 26/07/2013, 11:28 AM   #13
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,827
Reputation: 1401
Default Re: OnPlayerStateChange

Quote:
Originally Posted by JusstinRoller View Post
PHP Code:
stock MechanicCar(vehicleid)
{
    for(new 
i;<= sizeof(TowTrucks);i++)
    {
        if(
vehicleid == TowTrucks[i]) 
        {
            return 
1;
        }
    }
    return 
1;

That'd be:
pawn Code:
for(new i;i < sizeof(TowTrucks);i++)
Your code will be executed one more time (useless)
Plus you return both times (1). If the vehicleid is one of the TowTrucks return 1. If it did not find any, then return 0.

@Authur Debug your code, it's really helpful.
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 26/07/2013, 11:48 AM   #14
JusstinRoller
Big Clucker
 
JusstinRoller's Avatar
 
Join Date: Jul 2013
Posts: 99
Reputation: -4
Default Re: OnPlayerStateChange

have you see my sugestion?
JusstinRoller is offline   Reply With Quote
Old 26/07/2013, 04:23 PM   #15
Muhamed.pwn
Big Clucker
 
Join Date: Mar 2012
Posts: 67
Reputation: 0
Default Re: OnPlayerStateChange

Quote:
Originally Posted by JusstinRoller View Post
have you see my sugestion?

Yes I have, _Zeus replied.
Muhamed.pwn is offline   Reply With Quote
Old 27/07/2013, 10:09 PM   #16
Muhamed.pwn
Big Clucker
 
Join Date: Mar 2012
Posts: 67
Reputation: 0
Default Re: OnPlayerStateChange

Anyone got a such issue !?
I've looked into another gamemode and OnPlayerStateChange is exactly like min (stocks and checking) and I just can't figure out where the problem lies.
Muhamed.pwn is offline   Reply With Quote
Old 27/07/2013, 10:14 PM   #17
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,827
Reputation: 1401
Default Re: OnPlayerStateChange

Debug your code and you will see!
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 27/07/2013, 10:21 PM   #18
Muhamed.pwn
Big Clucker
 
Join Date: Mar 2012
Posts: 67
Reputation: 0
Default Re: OnPlayerStateChange

Quote:
Originally Posted by _Zeus View Post
Debug your code and you will see!
Debugged it already, it just won't come over the first check: "if(BusCar)..." while the BusCar stock returns 0 if the car isn't a bus and it stops the code from processing to the end!

Can't find a solution to process it to the end.
Muhamed.pwn is offline   Reply With Quote
Old 28/07/2013, 10:06 AM   #19
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,827
Reputation: 1401
Default Re: OnPlayerStateChange

When I meant "debug", I meant what the values are.

pawn Code:
printf("MechanicCar(GetPlayerVehicleID(playerid)) = %d", MechanicCar(GetPlayerVehicleID(playerid)));
if(MechanicCar(GetPlayerVehicleID(playerid))) // All the code under this don't work whatever I put under here
{
    printf("if(PlayerInfo[playerid][pJob] = %d", PlayerInfo[playerid][pJob]);
    if(PlayerInfo[playerid][pJob] == 2)
    {
        SendClientMessage(playerid,-1,"{1589FF} Welcome Mechanic.");
    }
    else SendClientMessage(playerid,COLOR_GREY,"This vehicle is LOCKED!"); RemovePlayerFromVehicle(playerid);
}
Show us what it prints out!

PS: MechanicCar needs the vehicleid or modelid?
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 28/07/2013, 03:42 PM   #20
Muhamed.pwn
Big Clucker
 
Join Date: Mar 2012
Posts: 67
Reputation: 0
Default Re: OnPlayerStateChange

Quote:
Originally Posted by _Zeus View Post
When I meant "debug", I meant what the values are.

pawn Code:
printf("MechanicCar(GetPlayerVehicleID(playerid)) = %d", MechanicCar(GetPlayerVehicleID(playerid)));
if(MechanicCar(GetPlayerVehicleID(playerid))) // All the code under this don't work whatever I put under here
{
    printf("if(PlayerInfo[playerid][pJob] = %d", PlayerInfo[playerid][pJob]);
    if(PlayerInfo[playerid][pJob] == 2)
    {
        SendClientMessage(playerid,-1,"{1589FF} Welcome Mechanic.");
    }
    else SendClientMessage(playerid,COLOR_GREY,"This vehicle is LOCKED!"); RemovePlayerFromVehicle(playerid);
}
Show us what it prints out!

PS: MechanicCar needs the vehicleid or modelid?
It doesn't even printed something.

MechanicCar needs vehicleid to determine if the players vehicleid he is in is equal to some of the towtrucks.
Muhamed.pwn 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
OnPlayerStateChange help.. Pettersen Scripting Help 2 18/05/2013 11:22 AM
OnPlayerStateChange stormchaser206 Scripting Help 3 13/07/2012 06:07 PM
OnPlayerStateChange Konstantinos Scripting Help 0 23/02/2012 08:29 PM
OnPlayerStateChange rati555 Scripting Help 1 22/12/2011 04:03 PM
OnPlayerStateChange help TouR Help Archive 6 23/12/2009 12:32 PM


All times are GMT. The time now is 09:11 AM.


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