SA-MP Forums Archive
Credit Cards - 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: Credit Cards (/showthread.php?tid=230853)



Credit Cards - marine - 24.02.2011

Ok, So I want to add credit cards into my script. However, I don't want to have the current players need to remake their accounts so I am trying to make it so when they try to buy a credit card, it detects if they have the line to change the 0 to a 1. here's what i have so far:

Код:
if(strcmp(cmd, "/buycc", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	        if(PlayerInfo[playerid][pCreditCard] = 0);
	        {
	            SetPlayerInfo[playerid][pCreditCard] = 1;
	        }
	        else if
	        {
 	    	    dini_IntSet(string3, "CreditCard",PlayerInfo[playerid][pCreditCard]);
 		}
 	    }
 	}
I realize of course, it's not finished, but I need some help on how to make it detect if there is CreditCard=0 in the player's file. what would i use for that?

Thanks for any help.


Re: Credit Cards - DaneAMattie - 24.02.2011

some little mistakes i think:
use this
pawn Код:
if(strcmp(cmd, "/buycc", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pCreditCard] == 0) //you need 2 == in if statements and don't use ; after a if
            {
                PlayerInfo[playerid][pCreditCard] = 1; // SetPlayerInfo is not a function i think
            }
            else //you had else if, else if wut? nothing so else
            {
                dini_IntSet(string3, "CreditCard",PlayerInfo[playerid][pCreditCard]);
        }
        }
    }



Re: Credit Cards - marine - 24.02.2011

You're right about the SetPlayerInfo. lol.
for the else if, some players do will not have [pCreditCard] in their .ini file so i need to somehow add it if they do not have it.


Re: Credit Cards - DaneAMattie - 24.02.2011

Quote:
Originally Posted by marine
Посмотреть сообщение
You're right about the SetPlayerInfo. lol.
for the else if, some players do will not have [pCreditCard] in their .ini file so i need to somehow add it if they do not have it.
Look at the new comments:
you better use when a player registers add this:
dini_IntSet(string3, "CreditCard",0); //(i dunno what string3 is, probly username?)
pawn Код:
if(strcmp(cmd, "/buycc", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pCreditCard] == 0) //If the player has not a credit card
            {
                PlayerInfo[playerid][pCreditCard] = 1; // Set a creditcard
                   dini_IntSet(string3, "CreditCard",PlayerInfo[playerid][pCreditCard]); // Better save it after buying
            }
            else if(PlayerInfo[playerid][pCreditCard] == 1)// If the player Has a credit card
                {
                 SendClientMessage(playerid,COLOR_RED,"ERROR: You already have a CC!");
                }
        }
    }



Re: Credit Cards - marine - 24.02.2011

for the most part yes.
but for whatever reason, it doesn't like the string3

error 017: undefined symbol "string3"


Re: Credit Cards - DaneAMattie - 24.02.2011

Quote:
Originally Posted by marine
Посмотреть сообщение
for the most part yes.
but for whatever reason, it doesn't like the string3

error 017: undefined symbol "string3"
it means its not defined, try new string3; on top of your script, i think string3 stands for the username? so proble there is somewhere GetPlayerName and format with string3


Re: Credit Cards - marine - 24.02.2011

that screws up and pops more errors up lol
Код:
C:\Users\Levis\Desktop\sampserver\gamemodes\larp.pwn(25157) : warning 219: local variable "string3" shadows a variable at a preceding level
C:\Users\Levis\Desktop\sampserver\gamemodes\larp.pwn(25419) : warning 219: local variable "string3" shadows a variable at a preceding level
C:\Users\Levis\Desktop\sampserver\gamemodes\larp.pwn(43813) : error 035: argument type mismatch (argument 1)
C:\Users\Levis\Desktop\sampserver\gamemodes\larp.pwn(59706) : warning 219: local variable "string3" shadows a variable at a preceding level
C:\Users\Levis\Desktop\sampserver\gamemodes\larp.pwn(83830) : warning 203: symbol is never used: "string3"
I was thinking though. if I changed this
Код:
dini_IntSet(string3, "CreditCard",PlayerInfo[playerid][pCreditCard]);
//change to
PlayerInfo[playerid][pCreditCard] = 1;
it would give them the credit card.
but would it erase everything else from the .ini ?


Re: Credit Cards - marine - 24.02.2011

FIXED!
I did as i stated above and it worked.
It added the required line needed and didn't screw up the player file.

Thanks for all of your help! ^_^


Re: Credit Cards - DaneAMattie - 24.02.2011

Quote:
Originally Posted by marine
Посмотреть сообщение
FIXED!
I did as i stated above and it worked.
It added the required line needed and didn't screw up the player file.

Thanks for all of your help! ^_^
no problem