problem with switch
#1

Hey, another day another problem :P

ehm now i have a problem with the swith-command:
Код:
zcmd(kaufe, playerid, params[])
{
	new pWaffe;
	if (!sscanf(params, "s", pWaffe)) 
	{
		switch (pWaffe)
		{
			case pWaffe = "deagle":
			{
				gAmmo[playerid] + 20;
				GivePlayerMoney(playerid, -300);
				SendClientMessage(playerid, GREEN, "Du hast dir eine Desert Eagle gekauft");
				GivePlayerWeapon(playerid, 24, gAmmo[playerid]);
				return 1;
			}
			default:
			{
				SendClientMessage(playerid, RED, "Die Waffe existiert nicht.");
				return 1;
			}
		}
	}
	else if (GetPlayerMoney(playerid) < 300)
	{
		SendClientMessage(playerid, RED, "Du hast nicht genug Geld.");
	}	
	else 
	{
		SendClientMessage(playerid, RED, "Anwendung: /kaufe deagle");
	}
	return 1;
}
i posted a topic before called "trouble with ammo-array" and i've still problems with that too. (i changed my method to zcmd since last topic.)

BTW so i just want to decide which weapon was chosen and give the player the weapon. there is only the desert eagle yet.
Reply
#2

Problem is - unlike in languages as PHP - PAWN doesn't support comparing strings in switch-case, so you might wanna go for if-clauses using strcmp instead.
Reply
#3

Okay, thanks.
i didnt know that.
i thought its easier....
Reply
#4

Leider nicht... PAWN halt.
Reply
#5

Quote:
Originally Posted by juice.j
Leider nicht... PAWN halt.
Talk English nab...
If you see a script made in german variables and texts doesn't give you right to talk in other languages than English...
Reply
#6

Watch it internet police is active!

You know how much crap I give about that?
Reply
#7

Please could u give a suggestion for the code? :S
i dont know how i do this, because if i do it like i think, you have to script an own if-else construction for each weapon.

BTW im only a "newbie" i think and its my first script, so sorry if its a simple solution and i didnt know.
Reply
#8

Just add me on MSN, I ll give you a short explanation in German...

...but to bug PlayON a little:

Add mich im MSN, ich erklдrs dir da.
Reply
#9

Quote:
Originally Posted by juice.j
Just add me on MSN, I ll give you a short explanation in German...

...but to bug PlayON a little:

Add mich im MSN, ich erklдrs dir da.
I don't coz you pwn3d yourself by translating it actually..
Reply
#10

I didn't translate anything, but threw in a line in German. Please don't talk nerdy internet language
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)