SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 26/05/2014, 03:51 PM   #1
rumen98
Huge Clucker
 
Join Date: Feb 2012
Posts: 291
Reputation: 14
Question Is this possible?

Now we have player1 and player2 example:
player1 have enums:
PHP Code:
pInfo[playerid][m4a1] - 10 // amount of m4a1
pInfo[playerid][ak47] - 15 // amount of ak47
rInfo[playerid][m4a1] - 2500 //price for m4a1
rInfo[playerid][ak47] - 3000 //price for ak47 
and now when player1 type /sellguns to freeze player, run animation DEALER and create dynamic checkpoint right in front of player1, and when player2 enter in that checkpoint to show it Dialog example:
PHP Code:
title Dealer (Dealer name)
menu0 Buy M4A1 $(rInfo[playerid][m4a1]) Available(pInfo[playerid][m4a1])
menu1 Buy AK-47 $(rInfo[playerid][ak47]) Available(pInfo[playerid][ak47]) 
and when player2 buy any weapon to check player1 do you have from it and when have to check money on player2 if they have enough to give him weapon and take his money and give it to player1 and remove one of pInfo[playerid][m4a1] ?? and when player1 type again /sellguns to remove freeze, animation and dynamic checkpoint.
Now can you explain to me how this thing can be done, if at all possible. Thanks in advance
__________________
Zombie Scripts:
Survival Realism (New release version 1.1)
Role Play Scripts:
Weapon Dealer (Arms Dealer)
IG Company System [Dynamic] (Illegal Gun Company)

Other Scripts:
Weapon skill system + saving
SMS System (Redeem Code System)
NOTE: Old scripts without support are not added.
rumen98 is offline   Reply With Quote
Old 26/05/2014, 03:54 PM   #2
S4t3K
Gangsta
 
S4t3K's Avatar
 
Join Date: Jan 2013
Posts: 864
Reputation: 165
Default Re : Is this possible?

Use :

ShowPlayerDialog
GivePlayerMoney with a negative amount
ClearAnimations
ApplyAnimation
OnPlayerEnterDynamicCP
CreateDynamicCP
IsPlayerInDynamicCP
DestroyDynamicCP
__________________
S4t3K is offline   Reply With Quote
Old 26/05/2014, 03:56 PM   #3
XK
Huge Clucker
 
XK's Avatar
 
Join Date: Mar 2014
Location: A Rare Place
Posts: 242
Reputation: 30
Default Re: Is this possible?

sure,when he enters the command use:
pawn Code:
TogglePlayerControllable(playerid,0);
use loop and loop all of the players in it,and set marker for them,when player enters that marker,show him the dialog,and under the dialog,do whatev er you want ,and check the player2's money,if it's the right amount,give him -[price you want]
and rInfo[playerid][m4a1] -= 1;
__________________
By XK:
And are we meant to guess your Request?

XK is offline   Reply With Quote
Old 26/05/2014, 03:59 PM   #4
rumen98
Huge Clucker
 
Join Date: Feb 2012
Posts: 291
Reputation: 14
Default Re: Is this possible?

Yes, but i dont know how to make that Dynamic Checkpoint (unique) for every player ...
__________________
Zombie Scripts:
Survival Realism (New release version 1.1)
Role Play Scripts:
Weapon Dealer (Arms Dealer)
IG Company System [Dynamic] (Illegal Gun Company)

Other Scripts:
Weapon skill system + saving
SMS System (Redeem Code System)
NOTE: Old scripts without support are not added.
rumen98 is offline   Reply With Quote
Old 26/05/2014, 04:05 PM   #5
XK
Huge Clucker
 
XK's Avatar
 
Join Date: Mar 2014
Location: A Rare Place
Posts: 242
Reputation: 30
Default Re: Is this possible?

add this under the command
pawn Code:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
for(new i; i < MAX_PLAYERS; i++)
{
      if(IsPlayerConnected(i))
      {
             SetPlayerCheckPoint(i, x, y+1, z, 3.0); // make the checkpoint infront of the player
      }
}
__________________
By XK:
And are we meant to guess your Request?

XK is offline   Reply With Quote
Old 26/05/2014, 04:18 PM   #6
S4t3K
Gangsta
 
S4t3K's Avatar
 
Join Date: Jan 2013
Posts: 864
Reputation: 165
Default Re : Is this possible?

that's pretty easy

PHP Code:

new uniquesCheckpoints[MAX_PLAYERS];

CMD:sellguns(playeridparams[])
{
      
// Your code here
      
uniquesCheckpoints[playerid] = CreateDynamicCP(parameters);
      return 
1;

__________________
S4t3K is offline   Reply With Quote
Old 26/05/2014, 04:21 PM   #7
rumen98
Huge Clucker
 
Join Date: Feb 2012
Posts: 291
Reputation: 14
Default Re: Re : Is this possible?

Quote:
Originally Posted by S4t3K View Post
that's pretty easy

PHP Code:

new uniquesCheckpoints[MAX_PLAYERS];

CMD:sellguns(playeridparams[])
{
      
// Your code here
      
uniquesCheckpoints[playerid] = CreateDynamicCP(parameters);
      return 
1;

Hm yes ok, but when player2-3-4-5... enter in that checkpoint which is created by player1 how to make unique Dialog for that player when someone buy weapon, example to give money to player1 and take from it m4a1 or ak47 ?
__________________
Zombie Scripts:
Survival Realism (New release version 1.1)
Role Play Scripts:
Weapon Dealer (Arms Dealer)
IG Company System [Dynamic] (Illegal Gun Company)

Other Scripts:
Weapon skill system + saving
SMS System (Redeem Code System)
NOTE: Old scripts without support are not added.
rumen98 is offline   Reply With Quote
Old 26/05/2014, 04:33 PM   #8
S4t3K
Gangsta
 
S4t3K's Avatar
 
Join Date: Jan 2013
Posts: 864
Reputation: 165
Default Re : Is this possible?

I didn't really understand.

A dialog is unique by definition : when a player shows a dialog, you act on a "playerid" var, and playerid is the id of each player who shows the dialog.

So a code like that

PHP Code:

new cp[MAX_PLAYERS];

CMD:sellguns(playeridparams[])
{
      
cp[playerid] = CreateDynamicCP(params);
      return 
1;
}

public 
OnPlayerEnterDynamicCP(playeridcheckpointid)
{
      foreach(new 
Player)
      {
            if(
cp[p] == checkpointid)
            {
                  
SetPVarInt(playerid"WeaponSeller"p);
                  return 
ShowPlayerDialog(playeridDIALOG_WEAPONSDIALOG_STYLE_LIST"Buying weapons""M4\nAk-47\n""Buy""Close");
            }
      }
      return 
1;
}

public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
      if(
dialogid == DIALOG_WEAPONS)
      {
            if(!
response) return 1;
            if(
listitem == 0)
            {
                  
GivePlayerWeapon(playerid31999);
                  
GivePlayerMoney(playerid, -price_of_the_m4);
                  
GivePlayerMoney(GetPVarInt(playerid"WeaponSeller"), price_of_the_m4);
                  return 
1;
            }
            else if(
listitem == 1)
            {
                  
GivePlayerWeapon(playerid30999);
                  
GivePlayerMoney(playerid, -price_ak_47);
                  
GivePlayerMoney(GetPVarInt(playerid"WeaponSeller"), price_ak_k7);
                  return 
1;
            }
      }
      return 
0;
}

public 
OnPlayerExitDynamicCP(playeridcheckpointid)
{
      foreach(new 
Players)
      {
            if(
checkpointid == cp[p]) DeletePVar(playerid"WeaponSeller");
      }

Will work as a charm.
__________________
S4t3K 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



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


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