Weird error with my job
#1

Hey everyone, I made a job in a RP gamemode im working on. Its a delivery job and everything works great except one thing. I wanted to make it so when you get in the delivery truck, it rememberd which one your in and if you leave, tells you not to lose it or youl lose your cash and if you change truck then you lose your cash and it tells you to continue to the marker, etc.
Whats happening is the truck you get in saves, but when you deliver the trucks and drop it back off. The value isnt resetting and i have no idea why. Can someone please take a look at what im doing wrong?

Its only a small problem I know but I want it to be perfect! Feel free to ask for anymore information at all! Ill gladly provide anything. I want to get this fixed as soon as possible Thanks heaps everyone.
removed the code since this error cant be fixed for reasons unexplainable.. :/
Reply
#2

Protip: You might want to use switch more, it'll save you a lot of writing else if statements. Where is the code which handles successful delivery (which should happen on 11 checkpoint I guess)?
Reply
#3

Oops my bad sorry forgot that one! I havnt learned switches yet :/ haha ...

Dynamic Checkpoint 0
Thanks for the reply too. Hope we can fix this.
Reply
#4

Oh and when they enter a marker that is at a delivery location...
Reply
#5

This is quite complex. Could describe a little more what is wrong? I mean, you can fully complete one delivery, and after you return to base to get money, you can't take any new deliveries and get error about mismatching trucks? You are calling
pawn Код:
PlayerInfo[playerid][pDeliveryVeh] = -1;
so it shouldn't happen

You can actually shorten your

pawn Код:
if(DeliveryMission[playerid] == 1) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[1],1);
        else if(DeliveryMission[playerid] == 2) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[2],1);
        else if(DeliveryMission[playerid] == 3) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[3],1);
        else if(DeliveryMission[playerid] == 4) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[4],1);
        else if(DeliveryMission[playerid] == 5) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[5],1);
        else if(DeliveryMission[playerid] == 6) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[6],1);
        else if(DeliveryMission[playerid] == 7) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[7],1);
        else if(DeliveryMission[playerid] == 8) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[8],1);
        else if(DeliveryMission[playerid] == 9) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[9],1);
        else if(DeliveryMission[playerid] == 10) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[10],1);
        else if(DeliveryMission[playerid] == 11) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[11],1);
to

pawn Код:
if(DeliveryMission[playerid] >= 1 && DeliveryMission[playerid] <= 11) return TogglePlayerDynamicCP(playerid, DeliveryJobCP[DeliveryMission[playerid]], 1);
https://sampwiki.blast.hk/wiki/Control_Structures#switch_2 - this should help a lot
Reply
#6

yeah i thought it was complex. Im actually a pretty big beginner haha. But i planned it out and tried to do it and its mostly working. Im able to fully complete truck runs. as many as I want, also hand a truck in then go and continue with a new truck and hand that in aswel. The proble, is when you finish a truck and get a new one you get the error when you shouldnt be..
Do you know whats wrong. I have PlayerInfo[playerid][pDeliveryVeh] = -1;
But it doesnt seem to be working.? Iv even checked the saved userfiles and iv set it to reset when you log out.. doesnt happen.
Iv set it to reset when you die.. Not sure if that happens but i dont believe so.
Not entirely sure whats going on, can you help? Also, thanks for the tips ill look into it
Reply
#7

Hm, do you get the "wrong truck" error even at first truck? If yes
pawn Код:
if(PlayerInfo[playerid][pDeliveryVeh] != GetPlayerVehicleID(playerid))

//To

if(-1 != PlayerInfo[playerid][pDeliveryVeh] && PlayerInfo[playerid][pDeliveryVeh] != GetPlayerVehicleID(playerid))

I can see bright future ahead of you if you call yourself a beginner - apart from minor stuff it's nicely planned and written
Reply
#8

Really, wow that actually just made me feel soo good dude. Thanks so much, really. Im hell smiling right now!
:::DDD wow. aaanyways..
No. It doesnt happen on the firs truck. If you wanted I could chuck the server on real quick and you could have a test run. I really wana nail this!
Reply
#9

If changing this conditional doesn't help:

You can try debugging by placing
pawn Код:
printf("Current truck id for %d is %d when doing [here some more info about when you display it]", playerid, PlayerInfo[playerid][pDeliveryVeh]);
in a lot of places, or something. I can't help you because code you've provided is correct, so probably the error lays somewhere else. Or if you trust me you can provide whole GM so I can dig deeper, but I understand if you don't want to do this

Also is -1 the default value of PlayerInfo[playerid][pDeliveryVeh]?
Reply
#10

Yes, it is the default value. I do trust you, I would happily give it to you. It makes me feel good that the code is good. :P I dont mean to feel like a tight ass though but I dont wana hand it out atm :P
So about the default value being -1 ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)