Sallary Problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Sallary Problem (
/showthread.php?tid=199718)
Sallary Problem -
Osviux - 16.12.2010
Ok i wanted to make a sallary, but it still doesnt give money to a player.
Код:
forward Sallary(playerid);
This is somewhere under OnPlayerEnterVehicle
Код:
new model = GetVehicleModel(vehicleid);
new spec = playerDB[playerid][specialybe];
if(model== 597 || model== 523 || model== 430 || model== 599 || model== 497)
{
if(playerDB[playerid][admin] || spec == 1)
{
SendClientMessage(playerid,0xD9E916FF,"* Text text you will get money bla bla bla !");
SetTimerEx("Sallary", 1000, true, "i", playerid); /// Dont mind the time, its just for testing
return 1;
}
ShowPlayerDialog(playerid, 2001, DIALOG_STYLE_MSGBOX,"Job", "You are not working in the right job", "Ok", "Next");
Stop(playerid);
return 1;
}
I put this into the back of the gamemode. (This checks the model of the vehicle the player is in and gives the specified amount of money).
Код:
public Sallary()
{
for(new playerid;playerid<MAX_PLAYERS;playerid++)
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return;
new vehicleid = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(vehicleid);
//Laikas sumoketi, ne? Puse minutes = puse algos.
if(model == 598 || model == 597 || model == 523 || model == 599 || model == 427) playerDB[playerid][banke]+=45;
else if(model == 544 || model == 416 || model == 489 || model == 505) playerDB[playerid][alga]+=55;
else if(model == 538) playerDB[playerid][alga]+=25;
else if(model == TOWTRUCK) playerDB[playerid][alga]+=35;
else if(model == SWEEPER) playerDB[playerid][alga]+=50;
else if(model == 524) playerDB[playerid][alga]+=40;
else if(model == DOZER) playerDB[playerid][alga]+=25;
else if(model == 421) playerDB[playerid][alga]+=45;
else if(model == TAXI || model== 438) playerDB[playerid][alga]+=80;
else if(model== 411) playerDB[playerid][alga]+=40;
else if(model == 446 || model == 424 ) playerDB[playerid][alga]+=40;
else if(model == NEWSVAN) playerDB[playerid][alga]+=55;
else if(model == 448) playerDB[playerid][alga]+=50;
else if(model == HOTDOG) playerDB[playerid][alga]+=55;
else if(model == 502) playerDB[playerid][alga]+=150;
else if(model == 516) playerDB[playerid][alga]+=50;
else if(model == 552) playerDB[playerid][alga]+=65;
else if(model == TUG) playerDB[playerid][alga]+=45;
else if(model == MOWER) playerDB[playerid][alga]+=50;
else if(model == 535) playerDB[playerid][alga]+=55;
else if(model == 500) playerDB[playerid][alga]+=50;//ginklu dyleriai
else if(model == 609 || model== 438) playerDB[playerid][alga]+=70;
else if(model == 522 || model == 522) playerDB[playerid][alga]+=20;
else if(model == 545 || model == 575 || model == 576 || model == 467 || model == 434) playerDB[playerid[alga]+=60;
else if(model == NEVADA || model == SHAMAL || model == RUSTLER) playerDB[playerid][alga]+=45;
else if(model == BAGGAGE) playerDB[playerid][alga]+=55;
else if(model == WINDSOR) playerDB[playerid][alga]+=70;
else if(model == 490) playerDB[playerid][alga]+=80;
else if(model == HUNTLEY) playerDB[playerid][alga]+=70;
else if(model == 479) playerDB[playerid][alga]+=50; // narkotiku dyleriai
else if(model == 484 || model == 452) playerDB[playerid][alga]+=35;
else if(model == 514 || model== 515 || model== 403) playerDB[playerid][alga]+=55;
else if(model == 456) playerDB[playerid][alga]+=40;
}
}
Well i drive one of those vehicles and i dont get any money. Wheres the problem?
Re: Sallary Problem -
Babul - 16.12.2010
add a
Код:
SendClientMessageToAll(ff5555ff,"Event # triggered");
infront of each important command which is suspected not to work.
Since you will add 4 or 5 lines, youll spot the bugged part in the script.
i want to mention that you forwarded Sallary(playerid); but the public Sallary() does not. remove it from
further i suggest you to use arrays for the payout value. this way you dont need the dozens of if/else if checks.
Код:
new VehicleIDSallaryAmount[212];
OnGamemodeInit()
{
VehicleIDSallaryAmount[144]=55;
VehicleIDSallaryAmount[016]=55;
VehicleIDSallaryAmount[089]=55;
VehicleIDSallaryAmount[105]=55;
VehicleIDSallaryAmount[138]=25;
}
and then use that array-ed amount in the payout. dont forget to add the 400 to the ID stored in the array, it saves 400 IDs.
Код:
new VehModelID=GetVehicleModelID(GetPlayerVehicle(playerid));
playerDB[playerid][alga]+=VehicleIDSallaryAmount[VehModelID-400];
btw, i dont see the cash transfered to the player. it only gets added to your database (yet), or you simply missed to post that code?