SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 12/01/2015, 12:15 PM   #1
Mijata
Gangsta
 
Mijata's Avatar
 
Join Date: Mar 2014
Location: Serbia
Posts: 632
Reputation: 8
Default [Help]Bomb

why all players get +5 score when bomb explode i want only for the one who set

+rep

Code:
#include <a_samp>
#define COLOR_RED 0xFF0000AA
#define COLOR_BLUE 0x0000BBAA
#define SCM




new PostaviTim[MAX_PLAYERS];
new PlantedBomb = 0;
new Explode;


public OnGameModeInit()
{
return 1;
}


public OnGameModeExit()
{
return 1;
}


public OnPlayerRequestClass(playerid, classid)
{
return 1;
}


public OnPlayerConnect(playerid)
{
    PostaviTim[playerid] = 0;
	return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
PostaviTim[playerid] = 0;
return 1;
}


public OnPlayerSpawn(playerid)
{
	if (PostaviTim[playerid] == 0)
	{
	    new Tim = random(2);
	  	switch(Tim)
	   	{
	    	case 0:
	     	{
	     	    PostaviTim[playerid] = 1;
	     	    //SetPlayerSkin(playerid, ID Skina); // Ovo stavi ako hoces
	     	}
	     	case 1:
	     	{


	     	    PostaviTim[playerid] = 2;
	     	    //SetPlayerSkin(playerid, ID Skina); // Ovo stavi ako hoces
	     	}
	    }
    }
	return 1;
}


public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}


public OnVehicleSpawn(vehicleid)
{
return 1;
}


public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}


public OnPlayerText(playerid, text[])
{
return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/plantbomb", cmdtext, true, 10) == 0)
	{
	    if (PostaviTim[playerid] == 2) return SendClientMessage (playerid, COLOR_RED, "Cops can't plant bomb");
		if (!IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216)) return SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
		if (PlantedBomb == 1) return SendClientMessage(playerid,COLOR_RED,"The bomb is already planted!");
		PlantedBomb = 1;
		GameTextForAll("~r~Bomb has been planted!",3000,5);
		Explode = SetTimer("Explosion",300000,0);
	}


	if (strcmp("/defusebomb", cmdtext, true, 10) == 0)
	{
	    if (PlantedBomb == 0) return SendClientMessage(playerid,COLOR_RED,"The bomb is not planted!");
		if (PostaviTim[playerid] == 2)
		{
			if (!IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216)) return SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
			SendClientMessage(playerid,COLOR_RED,"You are defusing a bomg, please wait.");
			SetTimer("Defusion",20000,0);
		}
		else
		{
			SendClientMessage (playerid, COLOR_RED, "Only cops can defuse bomb");
		}
	}
	return 0;
}
forward Explosion();
public Explosion()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        GivePlayerMoney(i, 10000);
		SetPlayerScore(i, GetPlayerScore(i) + 5);
		SendClientMessage(i, COLOR_RED, "Bomb:you got +5 score and 10000$ for planting bomb");
    }
	GameTextForAll("~r~Bomb exploded",6000,5);
	CreateExplosion(212.9239,1820.3402,6.4216,12,20.0);
    PlantedBomb = 0;
	return 1;
}
forward Defusion();
public Defusion()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        GivePlayerMoney(i, 10000);
		SetPlayerScore(i, GetPlayerScore(i) + 5);
		SendClientMessage(i, COLOR_RED, "Bomb:you got +5 score and 10000$ for defusing bomb");
    }
	KillTimer(Explode);
	GameTextForAll("~r~Bomb defused",6000,5);
	return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}


public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}


public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}


public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}


public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}


public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}


public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}


public OnRconCommand(cmd[])
{
return 1;
}


public OnPlayerRequestSpawn(playerid)
{
return 1;
}


public OnObjectMoved(objectid)
{
return 1;
}


public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}


public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}


public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}


public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}


public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}


public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}


public OnPlayerExitedMenu(playerid)
{
return 1;
}


public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}


public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}


public OnPlayerUpdate(playerid)
{
return 1;
}


public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}


public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}


public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}


public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}


public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
Mijata is offline   Reply With Quote
Old 12/01/2015, 12:17 PM   #2
Airman123
Big Clucker
 
Join Date: Aug 2014
Posts: 110
Reputation: 3
Default Re: [Help]Bomb

You have used the variable "i" and you defined it for MAX_PLAYERS, that is why all the players playing takes the 5 scores.
Airman123 is offline   Reply With Quote
Old 12/01/2015, 12:21 PM   #3
Mijata
Gangsta
 
Mijata's Avatar
 
Join Date: Mar 2014
Location: Serbia
Posts: 632
Reputation: 8
Default Re: [Help]Bomb

how to fix it?
Mijata is offline   Reply With Quote
Old 12/01/2015, 12:25 PM   #4
Ironboy
High-roller
 
Ironboy's Avatar
 
Join Date: Nov 2010
Location: Isle of Man
Posts: 1,942
Reputation: 433
Default Re: [Help]Bomb

Quote:
Originally Posted by Mijata View Post
how to fix it?
Use this

pawn Code:
#include <a_samp>
#define COLOR_RED 0xFF0000AA
#define COLOR_BLUE 0x0000BBAA
#define SCM




new PostaviTim[MAX_PLAYERS];
new PlantedBomb = 0;
new Explode;
new SetpScore[MAX_PLAYERS];

public OnGameModeInit()
{
return 1;
}


public OnGameModeExit()
{
return 1;
}


public OnPlayerRequestClass(playerid, classid)
{
return 1;
}


public OnPlayerConnect(playerid)
{
    PostaviTim[playerid] = 0;
    SetpScore[playerid] = 0;
    return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
PostaviTim[playerid] = 0;
SetpScore[playerid] = 0;
return 1;
}


public OnPlayerSpawn(playerid)
{
    if (PostaviTim[playerid] == 0)
    {
        new Tim = random(2);
        switch(Tim)
        {
            case 0:
            {
                PostaviTim[playerid] = 1;
                //SetPlayerSkin(playerid, ID Skina); // Ovo stavi ako hoces
            }
            case 1:
            {


                PostaviTim[playerid] = 2;
                //SetPlayerSkin(playerid, ID Skina); // Ovo stavi ako hoces
            }
        }
    }
    return 1;
}


public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}


public OnVehicleSpawn(vehicleid)
{
return 1;
}


public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}


public OnPlayerText(playerid, text[])
{
return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/plantbomb", cmdtext, true, 10) == 0)
    {
        if (PostaviTim[playerid] == 2) return SendClientMessage (playerid, COLOR_RED, "Cops can't plant bomb");
        if (!IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216)) return SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
        if (PlantedBomb == 1) return SendClientMessage(playerid,COLOR_RED,"The bomb is already planted!");
        PlantedBomb = 1;
        SetpScore[playerid] = 1;
        GameTextForAll("~r~Bomb has been planted!",3000,5);
        Explode = SetTimer("Explosion",300000,0);
    }


    if (strcmp("/defusebomb", cmdtext, true, 10) == 0)
    {
        if (PlantedBomb == 0) return SendClientMessage(playerid,COLOR_RED,"The bomb is not planted!");
        if (PostaviTim[playerid] == 2)
        {
            if (!IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216)) return SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
            SendClientMessage(playerid,COLOR_RED,"You are defusing a bomg, please wait.");
            SetTimer("Defusion",20000,0);
        }
        else
        {
            SendClientMessage (playerid, COLOR_RED, "Only cops can defuse bomb");
        }
    }
    return 0;
}
forward Explosion();
public Explosion()
{
    new playerid;
    if(SetpScore[playerid] == 1)
    {
        SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
        SetpScore[playerid] = 0;
    }
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        GivePlayerMoney(i, 10000);
        SendClientMessage(i, COLOR_RED, "Bomb:you got +5 score and 10000$ for planting bomb");
    }
    GameTextForAll("~r~Bomb exploded",6000,5);
    CreateExplosion(212.9239,1820.3402,6.4216,12,20.0);
    PlantedBomb = 0;
    return 1;
}
forward Defusion();
public Defusion()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        GivePlayerMoney(i, 10000);
        SetPlayerScore(i, GetPlayerScore(i) + 5);
        SendClientMessage(i, COLOR_RED, "Bomb:you got +5 score and 10000$ for defusing bomb");
    }
    KillTimer(Explode);
    GameTextForAll("~r~Bomb defused",6000,5);
    return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}


public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}


public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}


public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}


public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}


public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}


public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}


public OnRconCommand(cmd[])
{
return 1;
}


public OnPlayerRequestSpawn(playerid)
{
return 1;
}


public OnObjectMoved(objectid)
{
return 1;
}


public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}


public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}


public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}


public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}


public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}


public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}


public OnPlayerExitedMenu(playerid)
{
return 1;
}


public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}


public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}


public OnPlayerUpdate(playerid)
{
return 1;
}


public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}


public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}


public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}


public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}


public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}

EDIT: This must be the Explosion callback and you have to do the same on diffusion callback to get it working perfectly.

pawn Code:
forward Explosion();
public Explosion()
{
    new playerid;
    if(SetpScore[playerid] == 1)
    {
        SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
        SetpScore[playerid] = 0;
        GivePlayerMoney(playerid, 10000);
        SetPlayerScore(playerid, GetPlayerScore(i) + 5);
        SendClientMessage(playerid, COLOR_RED, "Bomb:you got +5 score and 10000$ for planting bomb");
    }
    GameTextForAll("~r~Bomb exploded",6000,5);
    CreateExplosion(212.9239,1820.3402,6.4216,12,20.0);
    PlantedBomb = 0;
    return 1;
}
__________________
Ironboy is offline   Reply With Quote
Old 12/01/2015, 12:26 PM   #5
Airman123
Big Clucker
 
Join Date: Aug 2014
Posts: 110
Reputation: 3
Default Re: [Help]Bomb

Code:
forward Defusion(playerid);
public Defusion(playerid)
{
        GivePlayerMoney(playerid, 10000);
	SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
	SendClientMessage(playerid, COLOR_RED, "Bomb:you got +5 score and 10000$ for defusing bomb");
	KillTimer(Explode);
	GameTextForAll("~r~Bomb defused",6000,5);
	return 1;
}
Try this ^^
Airman123 is offline   Reply With Quote
Old 12/01/2015, 12:26 PM   #6
ATGOggy
Gangsta
 
Join Date: Sep 2014
Location: Ls-rcr
Posts: 850
Reputation: 52
Default Re: [Help]Bomb

Change this:
PHP Code:
Explode SetTimer("Explosion",300000,0); 
to this:
PHP Code:
Explode SetTimerEx("Explosion",300000,0"i"playerid); 
And

this:
PHP Code:
forward Explosion();
public 
Explosion()
{
    new 
playerid;
    if(
SetpScore[playerid] == 1)
    {
        
SetPlayerScore(playeridGetPlayerScore(playerid) + 5);
        
SetpScore[playerid] = 0;
    }
    for(new 
0MAX_PLAYERSi++)
    {
        
GivePlayerMoney(i10000);
        
SendClientMessage(iCOLOR_RED"Bomb:you got +5 score and 10000$ for planting bomb");
    }
    
GameTextForAll("~r~Bomb exploded",6000,5);
    
CreateExplosion(212.9239,1820.3402,6.4216,12,20.0);
    
PlantedBomb 0;
    return 
1;

to this:
PHP Code:
forward Explosion(playerid);
public 
Explosion(playerid)
{
    
GivePlayerMoney(playerid10000);
    
SetPlayerScore(playeridGetPlayerScore(playerid) + 5);
    
SendClientMessage(playeridCOLOR_RED"Bomb:you got +5 score and 10000$ for planting bomb");
    
GameTextForAll("~r~Bomb exploded",6000,5);
    
CreateExplosion(212.9239,1820.3402,6.4216,12,20.0);
    
PlantedBomb 0;
    return 
1;

__________________
******: "I've said this before. People think that MySQL is some simple plug-and-play magic bullet that you can use to just make your mode instantly better. They don't realise that the "L" in "SQL" means "language". So instead of programming PAWN, and using a bit of this mystery thing, you are now programming in two languages at once. If you spend months learning PAWN, you should spend the same time learning SQL, if not more - it is probably the more complex of the two languages, and not something that just gets bolted on to the side."


I give and want only fair reps. I hate this: "hey bro, I rep you, rep me plz

Click below if you wanna be amazed:
http://Paid2Refer.com/ref.php?refId=291262
ATGOggy is offline   Reply With Quote
Old 12/01/2015, 12:28 PM   #7
Airman123
Big Clucker
 
Join Date: Aug 2014
Posts: 110
Reputation: 3
Default Re: [Help]Bomb

Yes ATGOGGY, You are right. btw GetPlayerScore(i) "GetPlayerScore(playerid)"
Airman123 is offline   Reply With Quote
Old 12/01/2015, 12:29 PM   #8
ATGOggy
Gangsta
 
Join Date: Sep 2014
Location: Ls-rcr
Posts: 850
Reputation: 52
Default Re: [Help]Bomb

Quote:
Originally Posted by Airman123 View Post
Yes ATGOGGY, You are right. btw GetPlayerScore(i) "GetPlayerScore(playerid)"
Oh, sorry. You are right. Edited.
__________________
******: "I've said this before. People think that MySQL is some simple plug-and-play magic bullet that you can use to just make your mode instantly better. They don't realise that the "L" in "SQL" means "language". So instead of programming PAWN, and using a bit of this mystery thing, you are now programming in two languages at once. If you spend months learning PAWN, you should spend the same time learning SQL, if not more - it is probably the more complex of the two languages, and not something that just gets bolted on to the side."


I give and want only fair reps. I hate this: "hey bro, I rep you, rep me plz

Click below if you wanna be amazed:
http://Paid2Refer.com/ref.php?refId=291262
ATGOggy is offline   Reply With Quote
Old 12/01/2015, 12:32 PM   #9
Mijata
Gangsta
 
Mijata's Avatar
 
Join Date: Mar 2014
Location: Serbia
Posts: 632
Reputation: 8
Default Re: [Help]Bomb

i will try now
Mijata is offline   Reply With Quote
Old 12/01/2015, 12:42 PM   #10
Mijata
Gangsta
 
Mijata's Avatar
 
Join Date: Mar 2014
Location: Serbia
Posts: 632
Reputation: 8
Default Re: [Help]Bomb

work thanks + rep for all
Mijata 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
[FilterScript] Bomb - seeks player continously with a nuclear bomb explosion sound! RajatPawar Filterscripts 7 24/02/2013 07:00 PM
/bomb = Activate Car Bomb DeltaAirlines12 Scripting Help 3 28/10/2012 06:09 PM
[HELP] Bomb ID akis_tze Help Archive 5 02/01/2010 02:56 PM
bomb nesty Help Archive 3 30/12/2009 09:07 PM
I want make the bomb . someone to stand on the spot, a bomb would work. uplovethai Help Archive 4 29/10/2009 02:19 PM


All times are GMT. The time now is 03:09 PM.


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