Author Topic: sa-mp script help  (Read 1895 times)

0 Members and 1 Guest are viewing this topic.

senara

  • Guest
sa-mp script help
« on: July 19, 2006, 07:10:00 PM »
to make my server (Stunt) more competitive i wanna give money for who reach some place (i will take out the heli and airplanes for this)
something like this: if you reach the roof of building in front of the bmx park in los santos you receive 1000 bucks.

to set the checkpoint is ok, my problem is the structure, because in the map appear only 1 checkpoint per time, i want all appearing. i want when you reach the checkpoint u must go far away to receive money when u reach again.

hope somebody understand me.

thanks

Offline JayFoxRox

  • Posts: 2221
    • View Profile
    • Homepage
sa-mp script help
« Reply #1 on: July 19, 2006, 07:12:32 PM »
You should have a timer which checks for current player location. So every1 only sees the closest checkpoint. I m coding almost the same btw

You can challenge ppl to reach ur location etc ^^
« Last Edit: July 19, 2006, 07:12:56 PM by Fox »

Offline gunner

  • Senior Member
  • Posts: 2721
    • View Profile
    • ZeroLives.com
sa-mp script help
« Reply #2 on: July 20, 2006, 12:35:58 AM »
Dude, that wont help the guy, im sure he already knew what you just said...

Offline JayFoxRox

  • Posts: 2221
    • View Profile
    • Homepage
sa-mp script help
« Reply #3 on: July 20, 2006, 04:30:38 AM »
Read again:


So you mean its allowed to select one twice - but only after going away?

Then you have to check for the last 5 checkpoints as sample (Store them in an array (playerid, checkpointid) checkpoint - then compare xyz and when the player reached the distance (use vector.inc) u simply remove the checkpoint from the array by putting a -1 in checkpoint id. And just before reaching a checkpoint

if (GetCheckpointID(playerid,checkpointid) == 1)
{
TextForPlayer playerid,"OMFG - Ya biatch - leave ! You have been here allready",rgb(255,0,0);
}
else{
TextForPlayer playerid,"Broammm.. You just earned 500$ ",rgb(0,255,0);
//Your givemoney command here
NextCheckpoint++;
CheckpointArray(playerid,NextCheckpoint) = CurrentCheckpoint
}

Getcheckpointid is simply checking if the Checkpoint array of the player returns the checkpointid given by the user. So it verifys that the user havent been before.

*cant remember if pawn needed {} or not - C does anyways so i made em too - depends on pawn editor too
* Ow and i forgot syntax of basic commands - simply look in ur a_sa-mp.inc - u will know which commands i mean

senara

  • Guest
sa-mp script help
« Reply #4 on: July 20, 2006, 09:24:56 AM »
i made it


Quote
//------------------------------------------------------------------------------

public OnPlayerSpawn(playerid)

{
SetPlayerCheckpoint(playerid,1460.8708,-786.5081,99.8605,3); //
SetPlayerCheckpoint(playerid,1815.9240,-1435.7183,35.9219,3); //
SetPlayerCheckpoint(playerid,1752.7170,-1409.1849,34.8133,3); //
SetPlayerCheckpoint(playerid,1871.5204,-1446.1597,28.7969,3); //
SetPlayerCheckpoint(playerid,2068.9219,-1829.4824,22.4531,3); //
SetPlayerCheckpoint(playerid,2039.2244,-1967.9883,23.5217,3); //
SetPlayerCheckpoint(playerid,1766.5111,-1708.9930,27.6206,3); //
SetPlayerCheckpoint(playerid,1765.7565,-1230.6735,91.6406,3); //



   GameTextForPlayer(playerid, "~g~STUNTS BY SENARA", 5000, 3);
}



//---------------------------------------------------------------------------

public OnPlayerEnterCheckpoint(playerid) {

new name[256];
   new string[256];

GivePlayerMoney(playerid,5000);//replace 1000 with the amount u want to give to player
        GetPlayerName(playerid, name, 5);// this will display the name of the player who reaches the finish check first.
         SendClientMessageToAll(COLOR_GREEN, string);
         DisablePlayerCheckpoint(playerid); //this disables the check point when a player enters it


}

no problems to compile, but the game crash when i reach one checkpoint, not the real crash, as error... sa-mp, so he close my server.

so i changed it to only one checkpoint, but still the problem

any idea?

Offline JayFoxRox

  • Posts: 2221
    • View Profile
    • Homepage
sa-mp script help
« Reply #5 on: July 20, 2006, 09:36:14 AM »
You can only show one checkpoint each time. Thats the limit..

Ow and ur string is Empty. Try out this

Code: [Select]
public OnPlayerSpawn(playerid)

{
SetPlayerCheckpoint(playerid,1460.8708,-786.5081,99.8605,3); //

GameTextForPlayer(playerid, "~g~STUNTS BY SENARA", 5000, 3);
}



//---------------------------------------------------------------------------

public OnPlayerEnterCheckpoint(playerid) {
GivePlayerMoney(playerid,5000);//replace 1000 with the amount u want to give to player
SendClientMessageToAll(COLOR_GREEN, "Bang - Sumone reached it");
DisablePlayerCheckpoint(playerid); //this disables the check point when a player enters it


}
« Last Edit: July 20, 2006, 09:47:04 AM by Fox »

senara

  • Guest
sa-mp script help
« Reply #6 on: July 20, 2006, 04:37:09 PM »
dudes im about to give up

Offline JayFoxRox

  • Posts: 2221
    • View Profile
    • Homepage
sa-mp script help
« Reply #7 on: July 20, 2006, 05:12:34 PM »
Giving up is for luzers

Try to understand how it works and find other ways of doing the stuff you want (Like only show closest location to work around the limit)

1. SA-MP can only handle one checkpoint for the player. So you cant have a list with checkpoints in the beginning.
2. new name[256];
new string[256];
These are strings which MUST be filled with an string before using (even if the string only includes 1 char)

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal